[R] Error in twitterR package

2016-06-14 Thread Seema Shelke via R-help
 Hi,
I am trying to use twitter package. I got  below error while authentication.
> setup_twitter_oauth(api_key,api_secret,access_token, access_token_secret)
[1] "Using direct authentication"
Error in check_twitter_oauth() : OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()'
I am using windows machine. Please find below code and software details;
library("twitteR")
library(httr)
library(ROAuth)
download.file(url="http://curl.haxx.se/ca/cacert.pem;, destfile="cacert.pem")
api_key  <-"xxx"
api_secret  <- "xxx"
access_token  <- " xxx"
access_token_secret  <- "xxx"
setup_twitter_oauth(api_key,api_secret,access_token, access_token_secret)
R version : Ri386 3.3.0R studio:  0.99.902 
Thanks,Seema
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

[R] help with r package "trip"

2016-06-14 Thread Alice Domalik
Hi List, 

I'm relatively new to R, so apologies if my question is rather elementary. 
I'm working with some bird tracking data and I would like to calculate the 
maximum distance traveled from the colony. 
For the maximum distance traveled, I was going to use the function homedist(). 
However, when I try to use this function I get the following error: 
Error: could not find function "homedist" 
Anyone know why I would get this error? I have been using other functions in 
"trip" without an issue. Is there an alternative way I can calculate this? 

Thanks in advance for any help! 

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] processing time too long

2016-06-14 Thread Jim Lemon
I'm still unsure of what you are attempting to do with this data.
First, it is very sparse, appearing to be the counts of occurrences of
2567 strings, some of which are recognizable English words. I suspect
that you are trying to get something very simple like the frequency of
these strings within whatever corpus they inhabit. The code you sent
does some manipulations I can understand, others seem to be redundant
or even discarded after they are performed. For instance, you write
the result file twice, line by line. You also try to access the
element "matrixdata$ID" when as far as I can see, it doesn't exist.
That would certainly stop the script. Without knowing what is supposed
to be the result of this, it is impossible to even analyze code that
runs (for quite a few minutes) and does not appear to produce any
output..

Jim

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] processing time too long

2016-06-14 Thread Jim Lemon
Hi Sashi,
Since I do not want to create a large fake data set and then
painstakingly test and debug your code, why not try your code with a
subset of the data, maybe only 400 rows. If that runs slowly, your
code is very inefficient (it looks as though it is). You can then
begin to identify where the efficiency of the code can be improved.

Jim


On Tue, Jun 14, 2016 at 10:41 PM, SHASHI SETH  wrote:
> Dear Jim,
>
> Thanks for ur suggesion. Earlier problem is solved with ur advise. My code
> is taking too long to
> execute, more than 30 hours. there are 40309 rows and 26952 columns. file
> size is 110 MB.Please guide
> me what is wrong.
>
> Shashi
> On Thu, 09 Jun 2016 14:27:17 +0530 Jim Lemon wrote
>>Hi Shashi,
>
> Without trying to go through all that code, your error is something
>
> simple. When you read in "matrixdata" right in the beginning, you are
>
> getting a data frame, not a vector or a matrix (which in some cases
>
> can be treated like a vector). That will cause trouble at some point.
>
> Another thing is that when you call this:
>
>
>
> if((sum > 0 && sums1 > 0 && sums2 > 0) != NA)
>
>
>
> you seem to be asking for the union of three multi-valued vectors (?)
>
> which will probably cause at least a warning, but the error suggests
>
> that at least one of these objects has an NA value somewhere. This
>
> might be because "dtm_500_1.CSV" (whatever that is) has NA values in
>
> it. The code is fairly obscure and I can only say that your best bet
>
> is probably to check the initial data frame for NA values and then
>
> print out the results of each step, or least
>
>
>
> cat(sum(is.na(x)),"\n")
>
>
>
> where x is the object you have just created. That should allow you to
>
> find where in the tangle of code the NAs are appearing.
>
>
>
> Jim
>
>
>
>
>
>
>
> On Thu, Jun 9, 2016 at 4:49 PM, SHASHI SETH wrote:
>
>> Hi Jim,
>
>>
>
>> I am getting the following error:
>
>> Error in if ((sum > 0 && sums1 > 0 && sums2 > 0) != NA) { :
>
>> missing value where TRUE/FALSE needed
>
>>
>
>>
>
>> I have including my code below for your review:
>
>>
>
>> fitness_1_data <- c();
>
>>
>
>> src="dtm_500_1.CSV"
>
>> matrixdata <- read.csv(src)
>
>>
>
>> #get no vector/column from file/matrix
>
>> noofvec <- length(matrixdata)
>
>>
>
>> #set no of records/rows/document
>
>> noofrecords <- length(matrixdata[,1])
>
>>
>
>> #set row index
>
>> rindex<-1;
>
>>
>
>> #preapare header
>
>> colindex<-1;
>
>> colList <- colnames(matrixdata)
>
>>
>
>> combine<-"";
>
>>
>
>> vec_fitness_data<- c();
>
>>
>
>> while(colindex <= length(colList))
>
>> {
>
>> fitness_1_data <- append(fitness_1_data,colList[colindex])
>
>>
>
>> colindex<- colindex+1
>
>> }
>
>>
>
>> #add two additional vector for percentage and cluster
>
>> fitness_1_data <- append(fitness_1_data,"percentage")
>
>> fitness_1_data <- append(fitness_1_data,"Cluster")
>
>>
>
>> write.table(as.list(fitness_1_data), file ="Result_500_cycle1.csv",append
>> =
>
>> TRUE,
>
>> row.names=FALSE, col.names=FALSE, sep=",")
>
>>
>
>> #end header record
>
>>
>
>> nestedloopindex <- 2
>
>>
>
>>
>
>> while( nestedloopindex <= noofrecords )
>
>> {
>
>>
>
>> #init of temperory variables
>
>> sums1 <- 0;
>
>> sums2 <- 0;
>
>> sum <- 0;
>
>>
>
>> #set initial index of column 2 ,coloumn one hold document no not
>
>> actual data
>
>> colindex <- 2;
>
>>
>
>> # combine <-"";
>
>>
>
>> vec1 <- c();
>
>> vec2 <- c();
>
>>
>
>> #add document number in vector
>
>> vec1 <- append(vec1,matrixdata[rindex,1]);
>
>> vec2 <- append(vec2,matrixdata[nestedloopindex,1]);
>
>>
>
>> #declaration of temp -out variable for calculation
>
>> #out <- 0;
>
>>
>
>>
>
>> while(colindex <= noofvec )
>
>> {
>
>>
>
>>
>
>> vec1 <- append(vec1,matrixdata[rindex,colindex]);
>
>> vec2 <- append(vec2,matrixdata[nestedloopindex,colindex]);
>
>>
>
>> sum = sum +
>
>> matrixdata[rindex,colindex]*matrixdata[nestedloopindex,colindex]
>
>>
>
>> sums1 <- sums1 + matrixdata[rindex,colindex]^2;
>
>>
>
>> sums2 <- sums2 + matrixdata[nestedloopindex,colindex]^2;
>
>>
>
>> colindex <- colindex+1
>
>> }
>
>>
>
>> if((sum > 0 && sums1 > 0 && sums2 > 0) != NA)
>
>> {
>
>>
>
>> out <- sum / ((sqrt(sums1) * sqrt(sums2)))
>
>> }else
>
>> {
>
>> out <-0
>
>> }
>
>>
>
>> vec1 <- append(vec1,out);
>
>> vec1 <-append(vec1, "1")
>
>> vec2 <- append(vec2, out);
>
>>
>
>>
>
>>
>
>> if(nestedloopindex==2)
>
>> {
>
>> write.table(as.list(vec1), file ="Result_500_cycle1.csv",append =
>
>> TRUE, row.names=FALSE, col.names=FALSE, sep=",")
>
>> write.table(as.list(vec2), file ="Result_500_cycle1.csv",append =
>
>> TRUE, row.names=FALSE, col.names=FALSE, sep=",")
>
>> nestedloopindex<- nestedloopindex+1
>
>> } else
>
>> {
>
>> write.table(as.list(vec2), file ="Result_500_cycle1.csv",append =
>
>> TRUE, row.names=FALSE, col.names=FALSE, sep=",")
>
>> nestedloopindex<- nestedloopindex+1
>
>> }
>
>>
>
>> }
>
>>
>
>>
>
>> With Best Regards,
>
>> Shashi
>
>>
>
>> On Thu, 09 Jun 2016 04:45:09 +0530 Jim Lemon wrote
>
>>>Hi John,

Re: [R] strange error message when using rnorm and rbinom

2016-06-14 Thread Jim Lemon
Hi JI,
The most likely problems are negative numbers for sd or "k" being
larger than the number of mu.m2 or disp.m2 values.

Jim

On Wed, Jun 15, 2016 at 4:06 AM, JI Cho  wrote:
> Dear R users,
>
> I have been using rnorm, rbinom and have been getting the following warning
> message when I do not have any NAs in my generated values.
>
> Warning messages:1: In rnorm(nref, mean = mu.m2[[k]], sd = 
> sqrt(disp.m2[[k]])) :
>   NAs produced
>
>
> In one of the resources I found in over the internet explains that the
> mean and sd should be declared as integers. So I tried that which did
> not solve the issue.
>
>
> Can anyone advise me on how to eliminate the warning message?
>
>
> Thank you.
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Installation of package "rio" broken

2016-06-14 Thread Uwe Ligges



On 14.06.2016 21:01, Ista Zahn wrote:

On Tue, Jun 14, 2016 at 3:19 PM,   wrote:

Hi all,

today I wanted to install package "rio". As it depends on package "feather" which is only 
available as source I have chosen to install "rio" from source. The installations fails with the 
following messages:


"feather" is available as in pre-compiled form for windows versions of
R >= 3.3.0. Your simplest course of action is probably to update to
the latest released version of R and install the pre-compiled
packages.




Indeed, you need at least R-3.0.0 as this is compiled with gcc-4.9.3 
that supports the new standard.


Best,
Uwe Ligges



Best,
Ista



-- cut --
* installing *source* package 'feather' ...
** Paket 'feather' erfolgreich entpackt und MD5 Summen überprüft
** libs

*** arch - i386
g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
-I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
-I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  -mtune=core2 -c RcppExports.cpp 
-o RcppExports.o
g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
-I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
-I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  -mtune=core2 -c feather-read.cpp 
-o feather-read.o
g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
-I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
-I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  -mtune=core2 -c feather-types.cpp 
-o feather-types.o
g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
-I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
-I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  -mtune=core2 -c feather-write.cpp 
-o feather-write.o
g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
-I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
-I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  -mtune=core2 -c feather/buffer.cc 
-o feather/buffer.o
g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
-I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
-I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  -mtune=core2 -c 
feather/feather-c.cc -o feather/feather-c.o
g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
-I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
-I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  -mtune=core2 -c feather/io.cc -o 
feather/io.o
feather/io.cc:18:0: warning: "NOMINMAX" redefined [enabled by default]
c:\program 
files\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../include/c++/4.6.3/i686-w64-mingw32/bits/os_defines.h:46:0:
 note: this is the location of the previous definition
g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
-I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
-I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  -mtune=core2 -c 
feather/metadata.cc -o feather/metadata.o
feather/metadata.cc:29:7: error: expected nested-name-specifier before 
'FBString'
feather/metadata.cc:29:7: error: 'FBString' has not been declared
feather/metadata.cc:29:16: error: expected ';' before '=' token
feather/metadata.cc:29:16: error: expected unqualified-id before '=' token
feather/metadata.cc:32:7: error: expected nested-name-specifier before 
'ColumnVector'
feather/metadata.cc:32:7: error: 'ColumnVector' has not been declared
feather/metadata.cc:32:20: error: expected ';' before '=' token
feather/metadata.cc:32:20: error: expected unqualified-id before '=' token
feather/metadata.cc:178:3: error: 'ColumnVector' does not name a type
feather/metadata.cc: In member function 'feather::Status 
feather::metadata::TableBuilder::Impl::Finish()':
feather/metadata.cc:146:5: error: 'FBString' was not declared in this scope
feather/metadata.cc:146:14: error: expected ';' before 'desc'
feather/metadata.cc:148:7: error: 'desc' was not declared in this scope
feather/metadata.cc:154:9: error: 'desc' was not declared in this scope
feather/metadata.cc:156:27: error: 'columns_' was not declared in this scope
feather/metadata.cc:157:34: error: unable to deduce 'auto' from ''
feather/metadata.cc: In member function 'void 
feather::metadata::TableBuilder::Impl::add_column(const 
flatbuffers::Offset&)':
feather/metadata.cc:173:5: error: 'columns_' was not declared in this scope
feather/metadata.cc: In constructor 
'feather::metadata::TableBuilder::TableBuilder()':
feather/metadata.cc:190:5: error: type 'feather::metadata::TableBuilder' is not 
a direct base of 'feather::metadata::TableBuilder'
make: *** [feather/metadata.o] Error 1
Warnung: Ausführung von Kommando 'make -f "Makevars" -f "C:/PROGRA~1/R/R-32~1.2/etc/i386/Makeconf" -f 
"C:/PROGRA~1/R/R-32~1.2/share/make/winshlib.mk" CXX='$(CXX1X) $(CXX1XSTD)' CXXFLAGS='$(CXX1XFLAGS)' 
CXXPICFLAGS='$(CXX1XPICFLAGS)' 

Re: [R] strange error message when using rnorm and rbinom

2016-06-14 Thread Bert Gunter
Do not believe everything you read on the internet!

"In one of the resources I found in over the internet explains that the
mean and sd should be declared as integers."

That is compete crap.  The mean of a norma/Gaussian can be any real;
the sd can be any positive real.
Moreover, one does not need to "declare" R variables. Have you gone
through any R tutorials? -- there are many good ones on the web.
Please do so if you haven't before posting here.

Cheers,
Bert

Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Jun 14, 2016 at 11:06 AM, JI Cho  wrote:
> Dear R users,
>
> I have been using rnorm, rbinom and have been getting the following warning
> message when I do not have any NAs in my generated values.
>
> Warning messages:1: In rnorm(nref, mean = mu.m2[[k]], sd = 
> sqrt(disp.m2[[k]])) :
>   NAs produced
>
>
> In one of the resources I found in over the internet explains that the
> mean and sd should be declared as integers. So I tried that which did
> not solve the issue.
>
>
> Can anyone advise me on how to eliminate the warning message?
>
>
> Thank you.
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] strange error message when using rnorm and rbinom

2016-06-14 Thread Tom Wright
As you probably already guessed we are going to need to see the
contents of nref, mu.m2 and disp.m2 to help.
dput(nref)
dput(mu.m2)
dput(disp.m2)

k might help too.

On Tue, Jun 14, 2016 at 2:06 PM, JI Cho  wrote:
> Dear R users,
>
> I have been using rnorm, rbinom and have been getting the following warning
> message when I do not have any NAs in my generated values.
>
> Warning messages:1: In rnorm(nref, mean = mu.m2[[k]], sd = 
> sqrt(disp.m2[[k]])) :
>   NAs produced
>
>
> In one of the resources I found in over the internet explains that the
> mean and sd should be declared as integers. So I tried that which did
> not solve the issue.
>
>
> Can anyone advise me on how to eliminate the warning message?
>
>
> Thank you.
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] strange error message when using rnorm and rbinom

2016-06-14 Thread JI Cho
Dear R users,

I have been using rnorm, rbinom and have been getting the following warning
message when I do not have any NAs in my generated values.

Warning messages:1: In rnorm(nref, mean = mu.m2[[k]], sd = sqrt(disp.m2[[k]])) :
  NAs produced


In one of the resources I found in over the internet explains that the
mean and sd should be declared as integers. So I tried that which did
not solve the issue.


Can anyone advise me on how to eliminate the warning message?


Thank you.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Installation of package "rio" broken

2016-06-14 Thread Ista Zahn
On Tue, Jun 14, 2016 at 3:19 PM,   wrote:
> Hi all,
>
> today I wanted to install package "rio". As it depends on package "feather" 
> which is only available as source I have chosen to install "rio" from source. 
> The installations fails with the following messages:

"feather" is available as in pre-compiled form for windows versions of
R >= 3.3.0. Your simplest course of action is probably to update to
the latest released version of R and install the pre-compiled
packages.

Best,
Ista

>
> -- cut --
> * installing *source* package 'feather' ...
> ** Paket 'feather' erfolgreich entpackt und MD5 Summen überprüft
> ** libs
>
> *** arch - i386
> g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
> -I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
> -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  
> -mtune=core2 -c RcppExports.cpp -o RcppExports.o
> g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
> -I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
> -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  
> -mtune=core2 -c feather-read.cpp -o feather-read.o
> g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
> -I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
> -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  
> -mtune=core2 -c feather-types.cpp -o feather-types.o
> g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
> -I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
> -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  
> -mtune=core2 -c feather-write.cpp -o feather-write.o
> g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
> -I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
> -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  
> -mtune=core2 -c feather/buffer.cc -o feather/buffer.o
> g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
> -I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
> -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  
> -mtune=core2 -c feather/feather-c.cc -o feather/feather-c.o
> g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
> -I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
> -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  
> -mtune=core2 -c feather/io.cc -o feather/io.o
> feather/io.cc:18:0: warning: "NOMINMAX" redefined [enabled by default]
> c:\program 
> files\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../include/c++/4.6.3/i686-w64-mingw32/bits/os_defines.h:46:0:
>  note: this is the location of the previous definition
> g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
> -I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
> -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  
> -mtune=core2 -c feather/metadata.cc -o feather/metadata.o
> feather/metadata.cc:29:7: error: expected nested-name-specifier before 
> 'FBString'
> feather/metadata.cc:29:7: error: 'FBString' has not been declared
> feather/metadata.cc:29:16: error: expected ';' before '=' token
> feather/metadata.cc:29:16: error: expected unqualified-id before '=' token
> feather/metadata.cc:32:7: error: expected nested-name-specifier before 
> 'ColumnVector'
> feather/metadata.cc:32:7: error: 'ColumnVector' has not been declared
> feather/metadata.cc:32:20: error: expected ';' before '=' token
> feather/metadata.cc:32:20: error: expected unqualified-id before '=' token
> feather/metadata.cc:178:3: error: 'ColumnVector' does not name a type
> feather/metadata.cc: In member function 'feather::Status 
> feather::metadata::TableBuilder::Impl::Finish()':
> feather/metadata.cc:146:5: error: 'FBString' was not declared in this scope
> feather/metadata.cc:146:14: error: expected ';' before 'desc'
> feather/metadata.cc:148:7: error: 'desc' was not declared in this scope
> feather/metadata.cc:154:9: error: 'desc' was not declared in this scope
> feather/metadata.cc:156:27: error: 'columns_' was not declared in this scope
> feather/metadata.cc:157:34: error: unable to deduce 'auto' from ' error>'
> feather/metadata.cc: In member function 'void 
> feather::metadata::TableBuilder::Impl::add_column(const 
> flatbuffers::Offset&)':
> feather/metadata.cc:173:5: error: 'columns_' was not declared in this scope
> feather/metadata.cc: In constructor 
> 'feather::metadata::TableBuilder::TableBuilder()':
> feather/metadata.cc:190:5: error: type 'feather::metadata::TableBuilder' is 
> not a direct base of 'feather::metadata::TableBuilder'
> make: *** [feather/metadata.o] Error 1
> Warnung: Ausführung von Kommando 'make -f "Makevars" -f 
> "C:/PROGRA~1/R/R-32~1.2/etc/i386/Makeconf" -f 
> "C:/PROGRA~1/R/R-32~1.2/share/make/winshlib.mk" CXX='$(CXX1X) $(CXX1XSTD)' 
> CXXFLAGS='$(CXX1XFLAGS)' CXXPICFLAGS='$(CXX1XPICFLAGS)' 
> 

Re: [R] Closing FTP sessions with RCurl

2016-06-14 Thread Tom Wright
No expert here, and this isn't tested. It seems you can set the
forbid.reuse option which will cause curl to shutdown the connection
after transfer is complete.

if(url.exists("http://www.omegahat.net/RCurl/index.html;)) {
   curl <- getCurlHandle()
   curlSetOpt(.opts=list(forbid.reuse=1),curl=curl)
   getURL("http://www.omegahat.net/RCurl/index.html;, curl = curl)
}

On Tue, Jun 14, 2016 at 2:41 PM, J Payne  wrote:
> Does anyone know how to close an FTP session with RCurl?  I am trying to 
> automate the process of downloading snow data from a government website, and 
> their server is throttling the connection after a few files are downloaded.  
> I contacted their system administrator, who wrote: “My suspicion at this 
> point is that the getURL commands are opened and perform the function asked, 
> then linger in wait for 15 minutes until or ftp server closes the idle 
> sessions. Is there a way to tell R to close the sessions?”
>
>
>
> I’ve perused the RCurl manual but I don’t see a way to close sessions.  I 
> tried copying the following example from the RCurl manual, but it didn’t 
> solve the problem.  I’m a novice at this and I don’t understand the 
> relationship between handles and sessions, so I am probably missing something.
>
>
>
> #EXAMPLE from getCurl(), p. 39
>
> if(url.exists("http://www.omegahat.net/RCurl/index.html;)) {
>
>curl = getCurlHandle()
>
>getURL("http://www.omegahat.net/RCurl/index.html;, curl = curl)
>
>#getCurlInfo(curl) # I skipped this step
>
>rm(curl) # release the curl! (does this end the session???)
>
> }
>
>
>
> Thanks!
>
>
>
> John
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] Installation of package "rio" broken

2016-06-14 Thread William Dunlap via R-help
Your log showed that g++ was given the flag -std=c++0x.  It should be
-std=c++11 so the 'using typename = blahblah' syntax works.  Either
your feather/src/Makevars is missing the line CXX_STD=CXX11 or your
version of R is lacking support for CXX_STD.


> g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.
 -I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include"
-I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall
-mtune=core2 -c feather/metadata.cc -o feather/metadata.o
> feather/metadata.cc:29:7: error: expected nested-name-specifier before
'FBString'

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Jun 14, 2016 at 12:19 PM,  wrote:

> Hi all,
>
> today I wanted to install package "rio". As it depends on package
> "feather" which is only available as source I have chosen to install "rio"
> from source. The installations fails with the following messages:
>
> -- cut --
> * installing *source* package 'feather' ...
> ** Paket 'feather' erfolgreich entpackt und MD5 Summen überprüft
> ** libs
>
> *** arch - i386
> g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.
>  -I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include"
> -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall
> -mtune=core2 -c RcppExports.cpp -o RcppExports.o
> g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.
>  -I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include"
> -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall
> -mtune=core2 -c feather-read.cpp -o feather-read.o
> g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.
>  -I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include"
> -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall
> -mtune=core2 -c feather-types.cpp -o feather-types.o
> g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.
>  -I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include"
> -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall
> -mtune=core2 -c feather-write.cpp -o feather-write.o
> g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.
>  -I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include"
> -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall
> -mtune=core2 -c feather/buffer.cc -o feather/buffer.o
> g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.
>  -I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include"
> -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall
> -mtune=core2 -c feather/feather-c.cc -o feather/feather-c.o
> g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.
>  -I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include"
> -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall
> -mtune=core2 -c feather/io.cc -o feather/io.o
> feather/io.cc:18:0: warning: "NOMINMAX" redefined [enabled by default]
> c:\program
> files\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../include/c++/4.6.3/i686-w64-mingw32/bits/os_defines.h:46:0:
> note: this is the location of the previous definition
> g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.
>  -I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include"
> -I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall
> -mtune=core2 -c feather/metadata.cc -o feather/metadata.o
> feather/metadata.cc:29:7: error: expected nested-name-specifier before
> 'FBString'
> feather/metadata.cc:29:7: error: 'FBString' has not been declared
> feather/metadata.cc:29:16: error: expected ';' before '=' token
> feather/metadata.cc:29:16: error: expected unqualified-id before '=' token
> feather/metadata.cc:32:7: error: expected nested-name-specifier before
> 'ColumnVector'
> feather/metadata.cc:32:7: error: 'ColumnVector' has not been declared
> feather/metadata.cc:32:20: error: expected ';' before '=' token
> feather/metadata.cc:32:20: error: expected unqualified-id before '=' token
> feather/metadata.cc:178:3: error: 'ColumnVector' does not name a type
> feather/metadata.cc: In member function 'feather::Status
> feather::metadata::TableBuilder::Impl::Finish()':
> feather/metadata.cc:146:5: error: 'FBString' was not declared in this scope
> feather/metadata.cc:146:14: error: expected ';' before 'desc'
> feather/metadata.cc:148:7: error: 'desc' was not declared in this scope
> feather/metadata.cc:154:9: error: 'desc' was not declared in this scope
> feather/metadata.cc:156:27: error: 'columns_' was not declared in this
> scope
> feather/metadata.cc:157:34: error: unable to deduce 'auto' from
> ''
> feather/metadata.cc: In member function 'void
> feather::metadata::TableBuilder::Impl::add_column(const
> flatbuffers::Offset&)':
> feather/metadata.cc:173:5: error: 'columns_' was not declared in this scope
> feather/metadata.cc: In constructor
> 'feather::metadata::TableBuilder::TableBuilder()':
> feather/metadata.cc:190:5: error: type 

[R] Installation of package "rio" broken

2016-06-14 Thread G . Maubach
Hi all,

today I wanted to install package "rio". As it depends on package "feather" 
which is only available as source I have chosen to install "rio" from source. 
The installations fails with the following messages:

-- cut --
* installing *source* package 'feather' ...
** Paket 'feather' erfolgreich entpackt und MD5 Summen überprüft
** libs

*** arch - i386
g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
-I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
-I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  -mtune=core2 
-c RcppExports.cpp -o RcppExports.o
g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
-I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
-I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  -mtune=core2 
-c feather-read.cpp -o feather-read.o
g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
-I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
-I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  -mtune=core2 
-c feather-types.cpp -o feather-types.o
g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
-I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
-I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  -mtune=core2 
-c feather-write.cpp -o feather-write.o
g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
-I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
-I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  -mtune=core2 
-c feather/buffer.cc -o feather/buffer.o
g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
-I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
-I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  -mtune=core2 
-c feather/feather-c.cc -o feather/feather-c.o
g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
-I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
-I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  -mtune=core2 
-c feather/io.cc -o feather/io.o
feather/io.cc:18:0: warning: "NOMINMAX" redefined [enabled by default]
c:\program 
files\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../include/c++/4.6.3/i686-w64-mingw32/bits/os_defines.h:46:0:
 note: this is the location of the previous definition
g++ -m32 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.2/include" -DNDEBUG -I.   
-I"C:/Users/admin/Documents/R/win-library/3.2/Rcpp/include" 
-I"d:/RCompile/r-compiling/local/local320/include" -O2 -Wall  -mtune=core2 
-c feather/metadata.cc -o feather/metadata.o
feather/metadata.cc:29:7: error: expected nested-name-specifier before 
'FBString'
feather/metadata.cc:29:7: error: 'FBString' has not been declared
feather/metadata.cc:29:16: error: expected ';' before '=' token
feather/metadata.cc:29:16: error: expected unqualified-id before '=' token
feather/metadata.cc:32:7: error: expected nested-name-specifier before 
'ColumnVector'
feather/metadata.cc:32:7: error: 'ColumnVector' has not been declared
feather/metadata.cc:32:20: error: expected ';' before '=' token
feather/metadata.cc:32:20: error: expected unqualified-id before '=' token
feather/metadata.cc:178:3: error: 'ColumnVector' does not name a type
feather/metadata.cc: In member function 'feather::Status 
feather::metadata::TableBuilder::Impl::Finish()':
feather/metadata.cc:146:5: error: 'FBString' was not declared in this scope
feather/metadata.cc:146:14: error: expected ';' before 'desc'
feather/metadata.cc:148:7: error: 'desc' was not declared in this scope
feather/metadata.cc:154:9: error: 'desc' was not declared in this scope
feather/metadata.cc:156:27: error: 'columns_' was not declared in this scope
feather/metadata.cc:157:34: error: unable to deduce 'auto' from ''
feather/metadata.cc: In member function 'void 
feather::metadata::TableBuilder::Impl::add_column(const 
flatbuffers::Offset&)':
feather/metadata.cc:173:5: error: 'columns_' was not declared in this scope
feather/metadata.cc: In constructor 
'feather::metadata::TableBuilder::TableBuilder()':
feather/metadata.cc:190:5: error: type 'feather::metadata::TableBuilder' is not 
a direct base of 'feather::metadata::TableBuilder'
make: *** [feather/metadata.o] Error 1
Warnung: Ausführung von Kommando 'make -f "Makevars" -f 
"C:/PROGRA~1/R/R-32~1.2/etc/i386/Makeconf" -f 
"C:/PROGRA~1/R/R-32~1.2/share/make/winshlib.mk" CXX='$(CXX1X) $(CXX1XSTD)' 
CXXFLAGS='$(CXX1XFLAGS)' CXXPICFLAGS='$(CXX1XPICFLAGS)' 
SHLIB_LDFLAGS='$(SHLIB_CXX1XLDFLAGS)' SHLIB_LD='$(SHLIB_CXX1XLD)' 
SHLIB="feather.dll" OBJECTS="RcppExports.o feather-read.o feather-types.o 
feather-write.o"' ergab Status 2
ERROR: compilation failed for package 'feather'
* removing 'C:/Users/admin/Documents/R/win-library/3.2/feather'
Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-32~1.2/bin/x64/R" CMD INSTALL -l 
"C:\Users\admin\Documents\R\win-library\3.2" 

[R] Closing FTP sessions with RCurl

2016-06-14 Thread J Payne
Does anyone know how to close an FTP session with RCurl?  I am trying to 
automate the process of downloading snow data from a government website, and 
their server is throttling the connection after a few files are downloaded.  I 
contacted their system administrator, who wrote: “My suspicion at this point is 
that the getURL commands are opened and perform the function asked, then linger 
in wait for 15 minutes until or ftp server closes the idle sessions. Is there a 
way to tell R to close the sessions?”

 

I’ve perused the RCurl manual but I don’t see a way to close sessions.  I tried 
copying the following example from the RCurl manual, but it didn’t solve the 
problem.  I’m a novice at this and I don’t understand the relationship between 
handles and sessions, so I am probably missing something.

 

#EXAMPLE from getCurl(), p. 39

if(url.exists("http://www.omegahat.net/RCurl/index.html;)) {

   curl = getCurlHandle()

   getURL("http://www.omegahat.net/RCurl/index.html;, curl = curl)

   #getCurlInfo(curl) # I skipped this step

   rm(curl) # release the curl! (does this end the session???)

}

 

Thanks!

 

John


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] Haplo.glm error: Failed to converge during EM-glm loop

2016-06-14 Thread Ravi Varadhan
It is a "warning" message, but not an "error" message.  Therefore, you should 
still get parameter estimates.  However, lack of convergence is often an 
important issue. Although in the case of the EM algorithm, it may not be so 
serious since EM is notoriously slow to converge when you set a small tolerance 
for convergence. You may fiddle with the control options for EM algorithm and 
see if you can get convergence.  If not, you should contact the package authors.

Hope this is helpful,
Ravi

Ravi Varadhan, Ph.D. (Biostatistics), Ph.D. (Environmental Engg)
Associate Professor,  Department of Oncology
Division of Biostatistics & Bionformatics
Sidney Kimmel Comprehensive Cancer Center
Johns Hopkins University
550 N. Broadway, Suite -E
Baltimore, MD 21205
410-502-2619


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] is there a package in R or functions to calculate odds/hasard ratio from spline regression

2016-06-14 Thread takiy berrandou
Hello,

I'm looking for a package or function, which calculate OR/HR from spline
model regression. for example in SAS it exist some MACRO helping to do that
easiely.

i had make some research on the forum here and on the web but without any
succes.

thanks for the answers.

Takiy




-- 
Takiy BERRANDOU
0618916037
takiyedd...@gmail.com

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] two difficult loop

2016-06-14 Thread greg holly
Thanks a lot Jim. I am struggling to solve the problem.I do appreciate for
your helps and advice.

Greg

On Tue, Jun 14, 2016 at 3:39 AM, Jim Lemon  wrote:

> Hi Greg,
> This is obviously a problem with the data. The first error indicates
> that the sequence of integers regrange[1]:regrange[2] is too long to
> be allocated. Most likely this is because one or both of the endpoints
> are infinite. Maybe if you can find where the NAs are you can fix it.
>
> Jim
>
> On Tue, Jun 14, 2016 at 12:29 AM, greg holly  wrote:
> > Hi Jim;
> >
> > I do apologize if bothering. I have run on the real data and here is the
> > error message I got:
> >
> > Thanks,
> >
> > Greg
> >
> > start  end
> > Error in regrange[1]:regrange[2] : result would be too long a vector
> > In addition: Warning messages:
> > 1: In min(x) : no non-missing arguments to min; returning Inf
> > 2: In max(x) : no non-missing arguments to max; returning -Inf
> >
> > On Mon, Jun 13, 2016 at 10:28 AM, greg holly 
> wrote:
> >>
> >> Hi Jim;
> >>
> >> I do apologize if bothering. I have run on the real data and here is the
> >> error message I got:
> >>
> >> Thanks,
> >>
> >> Greg
> >>
> >> start  end
> >> Error in regrange[1]:regrange[2] : result would be too long a vector
> >> In addition: Warning messages:
> >> 1: In min(x) : no non-missing arguments to min; returning Inf
> >> 2: In max(x) : no non-missing arguments to max; returning -Inf
> >>
> >>
> >> On Mon, Jun 13, 2016 at 3:19 AM, Jim Lemon 
> wrote:
> >>>
> >>> Hi Greg,
> >>> Okay, I have a better idea now of what you want. The problem of
> >>> multiple matches is still there, but here is a start:
> >>>
> >>> # this data frame actually contains all the values in ref in the "reg"
> >>> field
> >>> map<-read.table(text="reg p rate
> >>>  10276 0.700  3.867e-18
> >>>  71608 0.830  4.542e-16
> >>>  29220 0.430  1.948e-15
> >>>  99542 0.220  1.084e-15
> >>>  26441 0.880  9.675e-14
> >>>  95082 0.090  7.349e-13
> >>>  36169 0.480  9.715e-13
> >>>  55572 0.500  9.071e-12
> >>>  65255 0.300  1.688e-11
> >>>  51960 0.970  1.163e-10
> >>>  55652 0.388  3.750e-10
> >>>  63933 0.250  9.128e-10
> >>>  35170 0.720  7.355e-09
> >>>  06491 0.370  1.634e-08
> >>>  85508 0.470  1.057e-07
> >>>  8 0.580  7.862e-07
> >>>  04758 0.810  9.501e-07
> >>>  06169 0.440  1.104e-06
> >>>  63933 0.750  2.624e-06
> >>>  41838 0.960  8.119e-06
> >>>  74806 0.810  9.501e-07
> >>>  92643 0.470  1.057e-07
> >>>  73732 0.090  7.349e-13
> >>>  82451 0.960  8.119e-06
> >>>  86042 0.480  9.715e-13
> >>>  93502 0.500  9.071e-12
> >>>  85508 0.370  1.634e-08
> >>>  95082 0.830  4.542e-16",
> >>>  header=TRUE)
> >>> # same as in your example
> >>> ref<-read.table(text="reg1 reg2
> >>>  29220 63933
> >>>  26441 41838
> >>>  06169 10276
> >>>  74806 92643
> >>>  73732 82451
> >>>  86042 93502
> >>>  85508 95082",
> >>>  header=TRUE)
> >>> # sort the "map" data frame
> >>> map2<-map[order(map$reg),]
> >>> # get a field for the counts
> >>> ref$n<-NA
> >>> # and a field for the minimum p values
> >>> ref$min_p<-NA
> >>> # get the number of rows in "ref"
> >>> nref<-dim(ref)[1]
> >>> for(i in 1:nref) {
> >>>  start<-which(map2$reg==ref$reg1[i])
> >>>  end<-which(map2$reg==ref$reg2[i])
> >>>  cat("start",start,"end",end,"\n")
> >>>  # get the range of matches
> >>>  regrange<-range(c(start,end))
> >>>  # convert this to a sequence spanning all matches
> >>>  allreg<-regrange[1]:regrange[2]
> >>>  ref$n[i]<-sum(map2$p[allreg] > 0.85)
> >>>  ref$min_p[i]<-min(map2$p[allreg])
> >>> }
> >>>
> >>> This example uses the span from the first match of "reg1" to the last
> >>> match of "reg2". This may not be what you want, so let me know if
> >>> there are further constraints.
> >>>
> >>> Jim
> >>>
> >>> On Mon, Jun 13, 2016 at 12:35 PM, greg holly 
> >>> wrote:
> >>> > Hi Bert;
> >>> >
> >>> > I do appreciate for this. I need check your codes on task2 tomorrow
> at
> >>> > my
> >>> > office on the real data as I have difficulty (because a technical
> >>> > issue) to
> >>> > remote connection. I am sure it will work well.
> >>> >
> >>> > I am sorry that I was not able to explain my first question.
> Basically
> >>> >
> >>> > Values in ref data represent the region of chromosome. I need choose
> >>> > these
> >>> > regions in map (all regions values in ref data are exist in map data
> in
> >>> > the
> >>> > first column -column map$reg). And then summing up the column
> "map$rate
> >>> > and
> >>> > count the numbers that gives >0.85. For example, consider  the first
> >>> > row in
> >>> > data ref. They are 29220   and  63933. After sorting the first column
> >>> > in
> >>> > map then summing column "map$rate" only between 29220   to  63933 in
> >>> > sorted
> >>> > map and cut off at >0.85. Then count how many rows in sorted map
> gives
> >>> >>0.85. For example consider there are 38 rows between 29220   in
> 

Re: [R-es] Ayuda con la homocedasticidad de Varianza

2016-06-14 Thread José Trujillo Carmona

El 14/06/16 a las 15:58, mora...@us.es escribió:

Hola, puedes calcular las cuasivarianzas muestrales por columnas
mediante tapply y luego
compararlas. El cociente entre las dos varianzas sigue una distribución
F de Snedecor con grados de libertad n1-1 y n2-2. Puedes calcular la
probabilidad de aceptar H0
con la función pf.



Eso solo es cierto si las variables constituyen muestras procedentes de 
variables aleatorias normales.


El cociente de varianzas solo sigue una distribución F de Snedecor en el 
caso de  variables normales. Incluso su comportamiento asintótico solo 
está indicado para muestras muy muy grandes.


Para variables no normales dispones de contrastes como el de 
Ansari-Bradley (en R es la función ansari.test), o el test de Moses (que 
es el que usa SPSS y en R está también disponible en el paquete DescTools).


En R hay disponibles otros como el de Mood o el de Siegel-Tukey, pero el 
primero de los señalados en el párrafo anterior tiene una gran potencia 
asintótica y el segundo es el más utilizado (por el efecto de 
penetración de mercado del SPSS).


Pero insisto, para las variables del ejemplo, es obvio que no se 
necesita ningún test: No hay ninguna razón para pensar que estas 
variables puedan compartir varianza. Ni siquiera el principio de 
parsimonia puede ser invocado para variables con distintas unidades de 
medida y escala como tienen las variables mostradas.


Saludos.

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] rlnorm behaviour

2016-06-14 Thread Thierry Onkelinx
You need to study my examples and the helpfile of ifelse more carefully.
Then you'll understand why your code is wrong.

​
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
Op 14 jun. 2016 17:47 schreef "Ayyappa Chaturvedula" :

> I am sorry, I missed that.  I think I made it more appropriate and not
> using unnecessary simulated values.  Thank you for your help.
>
> fulldata$Wt<-ifelse(fulldata$Sex==1,rlnorm(length(fulldata$Sex[fulldata$Sex==1]),
> meanlog = log(85.1), sdlog = sqrt(0.0329)),
> rlnorm(length(fulldata$Sex[fulldata$Sex==0]), meanlog
> = log(73), sdlog = sqrt(0.0442)))
>
> On Tue, Jun 14, 2016 at 10:42 AM, Thierry Onkelinx <
> thierry.onkel...@inbo.be> wrote:
>
>> Please keep r-help in cc.
>>
>> Yes. Have a look at this example
>>
>> ifelse(
>>   sample(c(TRUE, FALSE), size = 0.5 * length(letters), replace = TRUE),
>>   letters,
>>   LETTERS
>> )
>>
>>
>> ir. Thierry Onkelinx
>> Instituut voor natuur- en bosonderzoek / Research Institute for Nature
>> and Forest
>> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
>> Kliniekstraat 25
>> 1070 Anderlecht
>> Belgium
>>
>> To call in the statistician after the experiment is done may be no more
>> than asking him to perform a post-mortem examination: he may be able to say
>> what the experiment died of. ~ Sir Ronald Aylmer Fisher
>> The plural of anecdote is not data. ~ Roger Brinner
>> The combination of some data and an aching desire for an answer does not
>> ensure that a reasonable answer can be extracted from a given body of data.
>> ~ John Tukey
>>
>> 2016-06-14 17:31 GMT+02:00 Ayyappa Chaturvedula :
>>
>>> Thank you very much for your kind support.  The length of my condition
>>> vector is ~80 because I want only Sex==1 and else will be the other.  I
>>> understand now how ifelse works.  If the vector of the simulated vector is
>>> longer than the condition vector, then it takes the first few elements to
>>> match the length of condition vector and discards the rest?
>>>
>>> Regards,
>>> Ayyappa
>>>
>>> On Tue, Jun 14, 2016 at 10:15 AM, Thierry Onkelinx <
>>> thierry.onkel...@inbo.be> wrote:
>>>
 Dear Ayyappa,

 ifelse works on a vector. See the example below.

 ifelse(
   sample(c(TRUE, FALSE), size = length(letters), replace = TRUE),
   letters,
   LETTERS
 )

 However, note that it will recycle short vectors when they are not of
 equal length.

 ifelse(
   sample(c(TRUE, FALSE), size = 2 * length(letters), replace = TRUE),
   letters,
   LETTERS
 )

 In your code the length of the condition vector is 200, the length of
 the two other vectors is 100.

 Best regards,

 ir. Thierry Onkelinx
 Instituut voor natuur- en bosonderzoek / Research Institute for Nature
 and Forest
 team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
 Kliniekstraat 25
 1070 Anderlecht
 Belgium

 To call in the statistician after the experiment is done may be no more
 than asking him to perform a post-mortem examination: he may be able to say
 what the experiment died of. ~ Sir Ronald Aylmer Fisher
 The plural of anecdote is not data. ~ Roger Brinner
 The combination of some data and an aching desire for an answer does
 not ensure that a reasonable answer can be extracted from a given body of
 data. ~ John Tukey

 2016-06-14 17:02 GMT+02:00 Ayyappa Chaturvedula :

> Dear Group,
>
> I am trying to simulate a dataset with 200 individuals with random
> assignment of Sex (1,0) and Weight from lognormal distribution
> specific to
> Sex.  I am intrigued by the behavior of rlnorm function to impute a
> value
> of Weight from the specified distribution.  Here is the code:
> ID<-1:200
> Sex<-sample(c(0,1),200,replace=T,prob=c(0.4,0.6))
> fulldata<-data.frame(ID,Sex)
> fulldata$Wt<-ifelse(fulldata$Sex==1,rlnorm(100, meanlog = log(85.1),
> sdlog
> = sqrt(0.0329)),
> rlnorm(100, meanlog = log(73), sdlog =
> sqrt(0.0442)))
>
> mean(fulldata$Wt[fulldata$Sex==0]);to check the mean is close to 73
> mean(fulldata$Wt[fulldata$Sex==1]);to check the mean is close to 85
>
> I see that the number of simulated values has an effect 

Re: [R] detecting if a variable has changed

2016-06-14 Thread S Ellison
> > Nope, Ted. I asked for  a O(log(n)) solution, not an O(n) one.
> 
> I don't think that's possible with a numeric vector.  Inserting an entry
> at a random location is an O(n) operation, since you need to move all
> following values out of the way.

If the vector is presorted, wouldn't a binary search find the correct location 
in O(log(n))? (roughly log2(n)?) 

After that any insertion depends on how fast R can move memory about so the 
overall speed clearly depends on factors other than finding the location. 

S Ellison

***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] rlnorm behaviour

2016-06-14 Thread Ayyappa Chaturvedula
I am sorry, I missed that.  I think I made it more appropriate and not
using unnecessary simulated values.  Thank you for your help.

fulldata$Wt<-ifelse(fulldata$Sex==1,rlnorm(length(fulldata$Sex[fulldata$Sex==1]),
meanlog = log(85.1), sdlog = sqrt(0.0329)),
rlnorm(length(fulldata$Sex[fulldata$Sex==0]), meanlog =
log(73), sdlog = sqrt(0.0442)))

On Tue, Jun 14, 2016 at 10:42 AM, Thierry Onkelinx  wrote:

> Please keep r-help in cc.
>
> Yes. Have a look at this example
>
> ifelse(
>   sample(c(TRUE, FALSE), size = 0.5 * length(letters), replace = TRUE),
>   letters,
>   LETTERS
> )
>
>
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
> Forest
> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
> Kliniekstraat 25
> 1070 Anderlecht
> Belgium
>
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to say
> what the experiment died of. ~ Sir Ronald Aylmer Fisher
> The plural of anecdote is not data. ~ Roger Brinner
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
> 2016-06-14 17:31 GMT+02:00 Ayyappa Chaturvedula :
>
>> Thank you very much for your kind support.  The length of my condition
>> vector is ~80 because I want only Sex==1 and else will be the other.  I
>> understand now how ifelse works.  If the vector of the simulated vector is
>> longer than the condition vector, then it takes the first few elements to
>> match the length of condition vector and discards the rest?
>>
>> Regards,
>> Ayyappa
>>
>> On Tue, Jun 14, 2016 at 10:15 AM, Thierry Onkelinx <
>> thierry.onkel...@inbo.be> wrote:
>>
>>> Dear Ayyappa,
>>>
>>> ifelse works on a vector. See the example below.
>>>
>>> ifelse(
>>>   sample(c(TRUE, FALSE), size = length(letters), replace = TRUE),
>>>   letters,
>>>   LETTERS
>>> )
>>>
>>> However, note that it will recycle short vectors when they are not of
>>> equal length.
>>>
>>> ifelse(
>>>   sample(c(TRUE, FALSE), size = 2 * length(letters), replace = TRUE),
>>>   letters,
>>>   LETTERS
>>> )
>>>
>>> In your code the length of the condition vector is 200, the length of
>>> the two other vectors is 100.
>>>
>>> Best regards,
>>>
>>> ir. Thierry Onkelinx
>>> Instituut voor natuur- en bosonderzoek / Research Institute for Nature
>>> and Forest
>>> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
>>> Kliniekstraat 25
>>> 1070 Anderlecht
>>> Belgium
>>>
>>> To call in the statistician after the experiment is done may be no more
>>> than asking him to perform a post-mortem examination: he may be able to say
>>> what the experiment died of. ~ Sir Ronald Aylmer Fisher
>>> The plural of anecdote is not data. ~ Roger Brinner
>>> The combination of some data and an aching desire for an answer does not
>>> ensure that a reasonable answer can be extracted from a given body of data.
>>> ~ John Tukey
>>>
>>> 2016-06-14 17:02 GMT+02:00 Ayyappa Chaturvedula :
>>>
 Dear Group,

 I am trying to simulate a dataset with 200 individuals with random
 assignment of Sex (1,0) and Weight from lognormal distribution specific
 to
 Sex.  I am intrigued by the behavior of rlnorm function to impute a
 value
 of Weight from the specified distribution.  Here is the code:
 ID<-1:200
 Sex<-sample(c(0,1),200,replace=T,prob=c(0.4,0.6))
 fulldata<-data.frame(ID,Sex)
 fulldata$Wt<-ifelse(fulldata$Sex==1,rlnorm(100, meanlog = log(85.1),
 sdlog
 = sqrt(0.0329)),
 rlnorm(100, meanlog = log(73), sdlog =
 sqrt(0.0442)))

 mean(fulldata$Wt[fulldata$Sex==0]);to check the mean is close to 73
 mean(fulldata$Wt[fulldata$Sex==1]);to check the mean is close to 85

 I see that the number of simulated values has an effect on the mean
 calculated after imputation. That is, the code rlnorm(100, meanlog =
 log(73), sdlog = sqrt(0.0442)) gives much better match compared to
 rlnorm(1, meanlog = log(73), sdlog = sqrt(0.0442)) in ifelse statement
 in
 the code above.

 My understanding is that ifelse will be imputing only one value where
 the
 condition is met as specified.  I appreciate your insights on the
 behavior
 for better performance of increasing sample number.  I appreciate your
 comments.

 Regards,
 Ayyappa

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


Re: [R] rlnorm behaviour

2016-06-14 Thread Thierry Onkelinx
Please keep r-help in cc.

Yes. Have a look at this example

ifelse(
  sample(c(TRUE, FALSE), size = 0.5 * length(letters), replace = TRUE),
  letters,
  LETTERS
)


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2016-06-14 17:31 GMT+02:00 Ayyappa Chaturvedula :

> Thank you very much for your kind support.  The length of my condition
> vector is ~80 because I want only Sex==1 and else will be the other.  I
> understand now how ifelse works.  If the vector of the simulated vector is
> longer than the condition vector, then it takes the first few elements to
> match the length of condition vector and discards the rest?
>
> Regards,
> Ayyappa
>
> On Tue, Jun 14, 2016 at 10:15 AM, Thierry Onkelinx <
> thierry.onkel...@inbo.be> wrote:
>
>> Dear Ayyappa,
>>
>> ifelse works on a vector. See the example below.
>>
>> ifelse(
>>   sample(c(TRUE, FALSE), size = length(letters), replace = TRUE),
>>   letters,
>>   LETTERS
>> )
>>
>> However, note that it will recycle short vectors when they are not of
>> equal length.
>>
>> ifelse(
>>   sample(c(TRUE, FALSE), size = 2 * length(letters), replace = TRUE),
>>   letters,
>>   LETTERS
>> )
>>
>> In your code the length of the condition vector is 200, the length of the
>> two other vectors is 100.
>>
>> Best regards,
>>
>> ir. Thierry Onkelinx
>> Instituut voor natuur- en bosonderzoek / Research Institute for Nature
>> and Forest
>> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
>> Kliniekstraat 25
>> 1070 Anderlecht
>> Belgium
>>
>> To call in the statistician after the experiment is done may be no more
>> than asking him to perform a post-mortem examination: he may be able to say
>> what the experiment died of. ~ Sir Ronald Aylmer Fisher
>> The plural of anecdote is not data. ~ Roger Brinner
>> The combination of some data and an aching desire for an answer does not
>> ensure that a reasonable answer can be extracted from a given body of data.
>> ~ John Tukey
>>
>> 2016-06-14 17:02 GMT+02:00 Ayyappa Chaturvedula :
>>
>>> Dear Group,
>>>
>>> I am trying to simulate a dataset with 200 individuals with random
>>> assignment of Sex (1,0) and Weight from lognormal distribution specific
>>> to
>>> Sex.  I am intrigued by the behavior of rlnorm function to impute a value
>>> of Weight from the specified distribution.  Here is the code:
>>> ID<-1:200
>>> Sex<-sample(c(0,1),200,replace=T,prob=c(0.4,0.6))
>>> fulldata<-data.frame(ID,Sex)
>>> fulldata$Wt<-ifelse(fulldata$Sex==1,rlnorm(100, meanlog = log(85.1),
>>> sdlog
>>> = sqrt(0.0329)),
>>> rlnorm(100, meanlog = log(73), sdlog = sqrt(0.0442)))
>>>
>>> mean(fulldata$Wt[fulldata$Sex==0]);to check the mean is close to 73
>>> mean(fulldata$Wt[fulldata$Sex==1]);to check the mean is close to 85
>>>
>>> I see that the number of simulated values has an effect on the mean
>>> calculated after imputation. That is, the code rlnorm(100, meanlog =
>>> log(73), sdlog = sqrt(0.0442)) gives much better match compared to
>>> rlnorm(1, meanlog = log(73), sdlog = sqrt(0.0442)) in ifelse statement in
>>> the code above.
>>>
>>> My understanding is that ifelse will be imputing only one value where the
>>> condition is met as specified.  I appreciate your insights on the
>>> behavior
>>> for better performance of increasing sample number.  I appreciate your
>>> comments.
>>>
>>> Regards,
>>> Ayyappa
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Factor levels in training set

2016-06-14 Thread ch.elahe via R-help
Hi all, 
I want to use Supervised Self organizing Maps from Kohonen package for my data. 
I need to divide my df into training set and test set, but a part of my df 
contains column with factor levels and I don't know how to bring them into my 
training set. Currently I use the following command for my training set:
 
dt=sort(sample(nrow(df),nrow(df)*.7))
training=m[dt,]
till here I get no error but in the next step which I need to bring my training 
set in a matrix I face this error:

scale(df[training,])
error: 'x' should be numeric
Does anyone know how should I include column with factor levels in my df so 
that I don't get this error?
Thanks for any help,
Elahe

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Factor levels in training set

2016-06-14 Thread ch.elahe via R-help

 Hi all, 
I want to use Supervised Self organizing Maps from Kohonen package for my data. 
I need to divide my df into training set and test set, but a part of my df 
contains column with factor levels and I don't know how to bring them into my 
training set. Currently I use the following command for my training set:

dt=sort(sample(nrow(df),nrow(df)*.7))
training=m[dt,]
till here I get no error but in the next step which I need to bring my training 
set in a matrix I face this error:

scale(df[training,])
error: 'x' should be numeric
Does anyone know how should I include column with factor levels in my df so 
that I don't get this error?
Thanks for any help,
Elahe

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] rlnorm behaviour

2016-06-14 Thread Thierry Onkelinx
Dear Ayyappa,

ifelse works on a vector. See the example below.

ifelse(
  sample(c(TRUE, FALSE), size = length(letters), replace = TRUE),
  letters,
  LETTERS
)

However, note that it will recycle short vectors when they are not of equal
length.

ifelse(
  sample(c(TRUE, FALSE), size = 2 * length(letters), replace = TRUE),
  letters,
  LETTERS
)

In your code the length of the condition vector is 200, the length of the
two other vectors is 100.

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2016-06-14 17:02 GMT+02:00 Ayyappa Chaturvedula :

> Dear Group,
>
> I am trying to simulate a dataset with 200 individuals with random
> assignment of Sex (1,0) and Weight from lognormal distribution specific to
> Sex.  I am intrigued by the behavior of rlnorm function to impute a value
> of Weight from the specified distribution.  Here is the code:
> ID<-1:200
> Sex<-sample(c(0,1),200,replace=T,prob=c(0.4,0.6))
> fulldata<-data.frame(ID,Sex)
> fulldata$Wt<-ifelse(fulldata$Sex==1,rlnorm(100, meanlog = log(85.1), sdlog
> = sqrt(0.0329)),
> rlnorm(100, meanlog = log(73), sdlog = sqrt(0.0442)))
>
> mean(fulldata$Wt[fulldata$Sex==0]);to check the mean is close to 73
> mean(fulldata$Wt[fulldata$Sex==1]);to check the mean is close to 85
>
> I see that the number of simulated values has an effect on the mean
> calculated after imputation. That is, the code rlnorm(100, meanlog =
> log(73), sdlog = sqrt(0.0442)) gives much better match compared to
> rlnorm(1, meanlog = log(73), sdlog = sqrt(0.0442)) in ifelse statement in
> the code above.
>
> My understanding is that ifelse will be imputing only one value where the
> condition is met as specified.  I appreciate your insights on the behavior
> for better performance of increasing sample number.  I appreciate your
> comments.
>
> Regards,
> Ayyappa
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] rlnorm behaviour

2016-06-14 Thread Ayyappa Chaturvedula
Dear Group,

I am trying to simulate a dataset with 200 individuals with random
assignment of Sex (1,0) and Weight from lognormal distribution specific to
Sex.  I am intrigued by the behavior of rlnorm function to impute a value
of Weight from the specified distribution.  Here is the code:
ID<-1:200
Sex<-sample(c(0,1),200,replace=T,prob=c(0.4,0.6))
fulldata<-data.frame(ID,Sex)
fulldata$Wt<-ifelse(fulldata$Sex==1,rlnorm(100, meanlog = log(85.1), sdlog
= sqrt(0.0329)),
rlnorm(100, meanlog = log(73), sdlog = sqrt(0.0442)))

mean(fulldata$Wt[fulldata$Sex==0]);to check the mean is close to 73
mean(fulldata$Wt[fulldata$Sex==1]);to check the mean is close to 85

I see that the number of simulated values has an effect on the mean
calculated after imputation. That is, the code rlnorm(100, meanlog =
log(73), sdlog = sqrt(0.0442)) gives much better match compared to
rlnorm(1, meanlog = log(73), sdlog = sqrt(0.0442)) in ifelse statement in
the code above.

My understanding is that ifelse will be imputing only one value where the
condition is met as specified.  I appreciate your insights on the behavior
for better performance of increasing sample number.  I appreciate your
comments.

Regards,
Ayyappa

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] AR1 model using ARIMA

2016-06-14 Thread Jeff Newmiller
Looks like you forgot to read the Posting Guide, too. 
-- 
Sent from my phone. Please excuse my brevity.

On June 14, 2016 6:30:23 AM PDT, "T.Riedle"  wrote:
>Sorry, I forgot to attach the file.
>
>
> Dear R users,
>I have not received any help regarding my problem.
>
>The rolling window AR1 model returns an error if I run my code as
>follows:
>
>data<-GSDAF[,2]
>rollingarma<-rollapply(data,width=36,function(data)
>coef(arima(data,order=c(1,0,0
>Error in arima(data, order = c(1, 0, 0)) :
>non-stationary AR part from CSS
>
>However, what is wrong with my code?
>
> Can I use the arma() function as alternative? In this case the code is
>
>rollingarma<-rollapply(data,width=36,function(data)
>coef(arma(data,order=c(1,0),include.intercept = FALSE)))
>
>Unfortunately, I get following message:
>
> There were 50 or more warnings (use warnings() to see the first 50)
>
>warnings()
>Warning messages:
>In optim(coef, err, gr = NULL, hessian = TRUE, ...) :
>one-dimensional optimization by Nelder-Mead is unreliable:
>use "Brent" or optimize() directly
>
>How can I use Brent or optimize in this code?
>
> Thanks for your support.
>__
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Warning message in openxlsx

2016-06-14 Thread G . Maubach
Hi All,

I get the warning message

Warning message:
In styles$font : partial match of 'font' to 'fonts'

when executing


> xls_workbook <- t_create_workbook()
> xls_sheetname <- "Kunden"
> xls_ds_to_save <- ds_merge1
> xls_filename <- paste0(data_created, 
"_Merge1_BW-SAP-Kunden_cleaned.xlsx")
> t_add_sheet(workbook = xls_workbook,
+ sheetname = xls_sheetname,
+ dataset = xls_ds_to_save)
> t_write_xlsx(workbook = xls_workbook,
+  path = path_output,
+  filename = xls_filename,
+  overwrite = TRUE)

where t_create_workbook() is

return(createWorkbook())

and t_add_sheet() is

 addWorksheet(workbook,
sheetName = sheetname)
  writeDataTable(workbook, 
sheet = sheetname, 
x = dataset)
  ### writeDataTable writes data to a sheet an adds
  ### autofilter to the first line
  if (freeze_row <= 1 | freeze_col <= 1) {
NULL # do nothing
  }
  else {
freezePane(workbook,
  sheet = sheetname,
  firstActiveRow = freeze_row,
  firstActiveCol = freeze_col)
  }
 
  setColWidths(workbook,
sheet = sheetname,
cols = 1:ncol(dataset), 
widths = "auto")

and t_write_xlsx is

saveWorkbook(workbook, 
file = file.path(path, filename),
overwrite = overwrite)

I am woundring what "partial match of 'font' to 'fonts'" means cause I do 
not call it in the functions calls. I use these calls a lot in my programs 
but never got this message before.

What does this message mean? How can I avoid this message?

Kind regards

Georg Maubach

PS: You can find more information about the used functions by going to 
https://sourceforge.net/projects/r-project-utilities/files/?source=navbar 
.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R-es] Ayuda con la homocedasticidad de Varianza

2016-06-14 Thread morales
Hola, puedes calcular las cuasivarianzas muestrales por columnas
mediante tapply y luego
compararlas. El cociente entre las dos varianzas sigue una distribución
F de Snedecor con grados de libertad n1-1 y n2-2. Puedes calcular la
probabilidad de aceptar H0 
con la función pf.

El 14/06/2016 12:00, r-help-es-requ...@r-project.org escribió:

> Envíe los mensajes para la lista R-help-es a
> r-help-es@r-project.org
> 
> Para subscribirse o anular su subscripción a través de la WEB
> https://stat.ethz.ch/mailman/listinfo/r-help-es
> 
> O por correo electrónico, enviando un mensaje con el texto "help" en
> el asunto (subject) o en el cuerpo a:
> r-help-es-requ...@r-project.org
> 
> Puede contactar con el responsable de la lista escribiendo a:
> r-help-es-ow...@r-project.org
> 
> Si responde a algún contenido de este mensaje, por favor, edite la
> linea del asunto (subject) para que el texto sea mas especifico que:
> "Re: Contents of R-help-es digest...". Además, por favor, incluya en
> la respuesta sólo aquellas partes del mensaje a las que está
> respondiendo.
> 
> Asuntos del día:
> 
> 1. Ayuda con la homocedasticidad de Varianza
> (Francisco Ruben Castaneda Rivero)
> 2. Re: Ayuda con la homocedasticidad de Varianza
> (José Trujillo Carmona)
> 
> --
> 
> Message: 1
> Date: Mon, 13 Jun 2016 19:01:17 -0700
> From: Francisco Ruben Castaneda Rivero 
> To: R-help-es@r-project.org
> Subject: [R-es] Ayuda con la homocedasticidad de Varianza
> Message-ID:
> 
> Content-Type: text/plain; charset="UTF-8"
> 
> Buenas Tardes. He tenido problemas al obtener la Homogenidad de varianza de
> una base de datos ya que tengo 5 Variables bioticas (Especies) y 4
> Abioticas. El ejemplo es la siguiente:
> 
> Especie a Especie b Especie c Especie d  Especie e Profun Conc Temp Sediment
> 0 2 9 14 2 72 4.8 3.5 2
> 26 4 13 11 0 75 2.8 2.5 1
> 0 10 9 8 0 59 5.4 2.7 1
> 0 0 15 3 0 64 8.2 2.9 2
> 13 5 3 10 7 61 3.9 3.1 1
> 31 21 13 16 5 94 2.6 3.5 3
> 9 6 0 11 2 53 4.6 2.9 2
> 2 0 0 0 1 61 5.1 3.3 1
> 17 7 10 14 6 68 3.9 3.4 1
> 0 5 26 9 0 69 10 3 2
> 0 8 8 6 7 57 6.5 3.3 1
> 14 11 13 1 0 84 3.8 3.1 2
> 0 0 19 0 6 53 9.4 3 2
> 13 0 0 9 0 83 4.4 2.5 1
> 4 0 10 12 0 100 6.7 2.8 1
> 42 20 0 3 6 84 2.8 3 3
> 4 0 0 0 0 96 6.4 3.1 1
> 21 15 33 20 0 74 4.4 2.8 3
> 2 5 12 16 3 79 3.1 3.6 2
> 0 10 14 9 0 73 5.6 3 2
> 8 0 0 4 6 59 4.3 3.4 1
> 35 10 0 9 17 54 1.9 2.8 2
> 6 7 1 17 10 95 2.4 2.9 3
> 18 12 20 7 0 64 4.3 3 1
> 32 26 0 23 0 97 2 3 3
> 24 21 0 10 5 78 2.5 3.4 2
> 24 17 0 25 6 85 2.1 3 3
> 16 3 12 20 2 92 3.4 3.3 3
> 11 0 7 8 0 51 6 3 2
> 24 37 5 18 1 99 1.9 2.9 3
> Me gustaria obtener la homogeneidad de varianza por poder realizar un
> Análisis de Correlacción Canónica. El problema es que al utilizar Barlet o
> Levenne test no calcula los valores ya que se necesita una variable
> dependiente y Factor, y al meterlo como especie a y factor abiotico no lo
> calcula. En este caso yo solo quiero obtener la homogeneidad de varianza
> por columna ( si se puede).
> 
> Agradeceria su pronta respuesta y Muchisimas Gracias de antemano.
> 
> [[alternative HTML version deleted]]
> 
> --
> 
> Message: 2
> Date: Tue, 14 Jun 2016 10:51:07 +0200
> From: José Trujillo Carmona 
> To: r-help-es@r-project.org
> Subject: Re: [R-es] Ayuda con la homocedasticidad de Varianza
> Message-ID: <575fc57b.2080...@unex.es>
> Content-Type: text/plain; charset=windows-1252; format=flowed
> 
> No entiendo el problema.
> 
> ¿La cuestión es saber si las distintas variables tienen la misma varianza?
> 
> No es razonables esperar que la Temperatura, la concentración o la 
> profundidad tengan la misma varianza. La varianza tienen unidades y la 
> varianza depende de la unidad de medida. Y no es posible expresar la 
> temperatura en metros de profundidad (ni tendría sentido).
> 
> Por ejemplo la estatura, que en personas se puede distribuir entre 1.5 y 
> 2 metros podría estar en el orden de 0.005 m^2 a 0.007 m^2. Pero si 
> medimos en cm y la estatura está desde los 150 a 200 cm, la varianza 
> estaría entre 50 a 70 cm^2 (cuestión de multiplicar por 100^2) como se 
> estudia en las propiedades básicas de las varianzas.
> 
> Respecto de las variables "Bioticas", supongo que son frecuencias. Pasa 
> lo mismo aunque menos evidente. Aunque las frecuencias tienen siempre 
> como unidad de medida los individuos (quince individuos, siete 
> individuos) su distribución seguirá una distribución de Poisson o algo 
> parecido; es decir que su varianza dependerá de su media; o dicho de 
> otro modo, de lo abundante que sea la especie.
> 
> Si en una muestra esperamos del orden de 20 ejemplares, será fácil que 
> los valores reales observados estén entre 10 y 30; pero si esperamos 
> solo del orden de cinco valores la varianza no puede ser tan grande como 
> en el primer caso por razones 

[R] AR1 model using ARIMA

2016-06-14 Thread T.Riedle
Sorry, I forgot to attach the file.


 Dear R users,
I have not received any help regarding my problem.

The rolling window AR1 model returns an error if I run my code as follows:

data<-GSDAF[,2]
rollingarma<-rollapply(data,width=36,function(data) 
coef(arima(data,order=c(1,0,0
Error in arima(data, order = c(1, 0, 0)) :
non-stationary AR part from CSS

However, what is wrong with my code?

 Can I use the arma() function as alternative? In this case the code is

 rollingarma<-rollapply(data,width=36,function(data) 
coef(arma(data,order=c(1,0),include.intercept = FALSE)))

Unfortunately, I get following message:

 There were 50 or more warnings (use warnings() to see the first 50)

warnings()
Warning messages:
In optim(coef, err, gr = NULL, hessian = TRUE, ...) :
one-dimensional optimization by Nelder-Mead is unreliable:
use "Brent" or optimize() directly

How can I use Brent or optimize in this code?

 Thanks for your support.
__
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] summing up a column.

2016-06-14 Thread oslo via R-help
Jeff;
Thanks a lot. I do appreciate for this. I will try your codes.
Regards,
Oslo 

On Monday, June 13, 2016 11:47 PM, Jeff Newmiller 
 wrote:
 

 You did half of what Petr asked... but your email still looks unreadable
because you did not send it as text only. Look at [1] to see what we see, 
and why we want you to send plain text. What you see is not what we see.

This is an outer join... an inherently inefficient operation according to 
relational database theory. Most solutions to this type of problem are 
likely to be slow, but minimizing unnecessary use of memory can help and 
to do that you can overwrite existing values instead of successively 
concatenating longer vectors of results as you go.

To understand the solution below, you should execute individual 
expressions interactively as you step through the code to see what the 
intermediate values look like. In particular, expressions on the right 
side of assignments can be interactively entered at the console without 
changing the variables in the environment so do it as much as you need to 
in order to see what is happening.

# alignment not required, but HTML run-together lines not wanted
A <- structure( list( posA = c( 1L, 2L, 5L, 4L, 9L)
                    , posB = c( 9L, 7L, 12L, 7L, 13L)
                    )
              , .Names = c("posA", "posB")
              , class = "data.frame"
              , row.names = c(NA, -5L)
              )
B <- structure( list( pos = c( 4L, 2L, 7L, 1L, 13L, 12L, 9L)
                    , a = c(0.4, 0.1, 0.5, 0.4, 0.1, 0.2, 0.3)
                    , b = c(7L, 5L, 8L, 1L, 6L, 11L, 12L)
                    , c = c(0.8, 0.4, 0.32, 0.1, 0.13, 0.01, 0.23))
              , .Names = c("pos", "a", "b", "c")
              , class = "data.frame"
              , row.names = c(NA, -7L)
              )
# sort B
sB <- B[ order( B$pos ), ]
# performance: set aside memory to remember results
A$count07 <- NA
A$mina <- NA
for ( i in seq.int( nrow( A ) ) ) {
  # logical indexing vector
  idx <- A[ i, "posA" ] <= sB$pos & sB$pos <= A[ i, "posB" ]
  # only extract desired vector once
  a <- sB[ idx, "a" ]
  # sum adds logical values as if TRUE=1
  A[ i, "count07" ] <- sum( cumsum( a ) < 0.7 )
  A[ i, "mina" ] <-min( a )
}
print( A )

#=== sample interactive session for study after A and B are defined
#=== execute lines one at a time and study them!
order( B$pos )
B[ order( B$pos ), ]
sB <- B[ order( B$pos ), ]
A$count07 <- NA
A$mina <- NA
i <- 1
A[ i, "posA" ] 
A[ i, "posB" ]
sB$pos
A[ i, "posA" ] <= sB$pos
sB$pos <= A[ i, "posB" ] 
A[ i, "posA" ] <= sB$pos & sB$pos <= A[ i, "posB" ]
idx <- A[ i, "posA" ] <= sB$pos & sB$pos <= A[ i, "posB" ]
sB[ idx, "a" ]
a <- sB[ idx, "a" ]
cumsum( a )
cumsum( a ) < 0.7
sum( cumsum( a ) < 0.7 )
A[ i, "count07" ] <- sum( cumsum( a ) < 0.7 )
min( a )

--
[1] https://stat.ethz.ch/pipermail/r-help/2016-June/439404.html

On Mon, 13 Jun 2016, oslo via R-help wrote:

> Hi Petr;
> Thanks so much. Here are the questions and the dput(A) and dput(B). Basicaly 
> I have two questions;
>> dput(A)structure(list(posA = c(1L, 2L, 5L, 4L, 9L), posB = c(9L, 7L, 12L, 
>> 7L, 13L)), .Names = c("posA", "posB"), class = "data.frame", row.names = 
>> c(NA, -5L))> dput(B)structure(list(pos = c(4L, 2L, 7L, 1L, 13L, 12L, 9L), a 
>> = c(0.4, 0.1, 0.5, 0.4, 0.1, 0.2, 0.3), b = c(7L, 5L, 8L, 1L, 6L, 11L, 12L), 
>> c = c(0.8, 0.4, 0.32, 0.1, 0.13, 0.01, 0.23)), .Names = c("pos", "a", "b", 
>> "c"), class = "data.frame", row.names = c(NA, -7L))
> Q1) Values in A represent the region of chromosome. I need choose these 
> regions in B (all region in A are exist in B in a single column) and then 
> summing up the column "a in B and count the numbers that gives >0.7. For 
> example, consider  the first row in A. They are 1 and 9. After sorting the 
> first column in B then summing column "a" only between 1 to 9 in sorted B and 
> cut off at >0.7. Then count how many rows in sorted B gives >0.7. For example 
> there are only 5 rows between 1 to 9 in sorted B and only summing first 2 of 
> them  gives>0.7 . Then my answer is going to be 2
> Q2) What is the min value of B$a for given each intervals in A
> Regards,
> Oslo 
>
>    On Monday, June 13, 2016 8:05 AM, PIKAL Petr  
>wrote:
> 
>
> Ok.
>
> Instead of explaining what you have, please send a result of
>
> dput(B) and dput(A)
>
> And set you mail client to send plain text mail otherwise your code is barely 
> readable.
>
> What do you want to do with printed values?
>
> What is B? From this it seems that it is data frame but then you try to put 
> sorted data frame into a data frame column.
>
> B$possort=B[order(B$pos),]
>
> With such code and data frame I get an error.
>
> So please try to keep above mentioned when posting a query.
>
> Regards
> Petr
>
>
>> -Original Message-
>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of oslo via R-
>> help
>> Sent: Friday, June 10, 2016 11:09 PM
>> 

Re: [R] AR1 model using ARIMA

2016-06-14 Thread Duncan Murdoch

On 14/06/2016 7:46 AM, T.Riedle wrote:


Dear R users,
I have not received any help regarding my problem.


Please read the posting guide (see the link at the bottom of every 
message).  If you don't post reproducible code, it's much harder to help 
you.


Duncan Murdoch


The rolling window AR1 model returns an error if I run my code as follows:


rollingarma<-rollapply(data,width=36,function(data) 
coef(arima(data,order=c(1,0,0
Error in arima(data, order = c(1, 0, 0)) :
  non-stationary AR part from CSS

However, what is wrong with my code?

Can I use the arma() function as alternative? In this case the code is


rollingarma<-rollapply(data,width=36,function(data) 
coef(arma(data,order=c(1,0),include.intercept = FALSE)))

There were 50 or more warnings (use warnings() to see the first 50)


warnings()


Warning messages:

1: In optim(coef, err, gr = NULL, hessian = TRUE, ...) :

  one-dimensional optimization by Nelder-Mead is unreliable:

use "Brent" or optimize() directly

In this case, I get a warning message. How can I use Brent or optimize in this 
code?

Thanks for your support.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R-es] Ejecutar bloques con codigo

2016-06-14 Thread eric

Muchas gracias emilio,

Saludos,

eric.




On 06/12/2016 11:24 PM, Emilio L. Cano wrote:

Eric,

Puedes hacer source sobre ficheros generados "al vuelo" desde tu propio
script, combinando readLines, writeLines y grep (esto último para
filtrar los bloques, pero la dificultad de esto ya depende de cómo esté
tu script organizado)

Saludos,
Emilio

El 12 de junio de 2016, 23:16, eric > escribió:

h lo mire, ese comando se acerca a lo q necesito, pero la
diferencia es que los bloques de codigo estan dentro del mismo
script en que los quiero llamar, en cambio, source llama a archivos
externos con el codigo ... sacar el codigo a archivos externos no es
tan buena opcion para mi porque el codigo ya cumple una funcion en
el lugar donde esta dentro del script, pero a veces necesito
ejecutar solo porciones de el, por eso marco los bloques dentro de
rkward ... por eficiencia y comodidad preferiria llamar esos bloques
marcados dentro del script con una linea de codigo y no con
shortcut, ese es el asunto que quiero resolver

muchas gracias,

saludos, eric.





On 06/12/2016 03:12 PM, JCMld wrote:

Quizas lo que buscas es el comando source?

Teclea ?source

Saludos,
Joan

-Mensaje original-
De: R-help-es [mailto:r-help-es-boun...@r-project.org
] En nombre de eric
Enviado el: domingo, 12 de junio de 2016 15:00
Para: Lista R
Asunto: [R-es] Ejecutar bloques con codigo

Estimados, estoy usando R desde rkward y quisiera saber, porque
no lo he
encontrado  ni logrado, si es posible ejecutar bloques de codigo
usando
alguna instruccion de R. Me explico ...en rkward es posible
marcar trozos de
codigo y luego ejecutarlos pinchando los iconos o en el manu o
usando
short-cuts (Ctrl+Shift+F1 por ejemplo)... pero yo quisiera hacer
eso usando
alguna instruccion de codigo ... es esto posible ? si es
posible, como se
hace ?

Por distintas razones, tengo trozos en distintos lugares de un
script que
debo ejecutar no siempre en el mismo orden y lo mas comodo para
mi seria
usando codigo.

Alguna idea ?


Muchas gracias,

Saludos,

Eric.






--
Forest Engineer
Master in Environmental and Natural Resource Economics Ph.D.
student in
Sciences of Natural Resources at La Frontera University Member in
AguaDeTemu2030, citizen movement for Temuco with green city
standards for
living

Nota: Las tildes se han omitido para asegurar compatibilidad con
algunos
lectores de correo.

___
R-help-es mailing list
R-help-es@r-project.org 
https://stat.ethz.ch/mailman/listinfo/r-help-es



--
Forest Engineer
Master in Environmental and Natural Resource Economics
Ph.D. student in Sciences of Natural Resources at La Frontera University
Member in AguaDeTemu2030, citizen movement for Temuco with green
city standards for living

Nota: Las tildes se han omitido para asegurar compatibilidad con
algunos lectores de correo.

___
R-help-es mailing list
R-help-es@r-project.org 
https://stat.ethz.ch/mailman/listinfo/r-help-es




--
*
*
*Emilio López Cano*
Data Scientist

Mobile: +34 665 676 225
skype: emilopezcano
twitter: @emilopezcano
http://emilio.lcano.com

*Affiliations / Collaborations:*
Rey Juan Carlos University
University of Castilla-La Mancha
Comunidad R-Hispano
AEC - AENOR - SKITES - talentyon



--
Forest Engineer
Master in Environmental and Natural Resource Economics
Ph.D. student in Sciences of Natural Resources at La Frontera University
Member in AguaDeTemu2030, citizen movement for Temuco with green city standards 
for living

Nota: Las tildes se han omitido para asegurar compatibilidad con algunos 
lectores de correo.

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[R] AR1 model using ARIMA

2016-06-14 Thread T.Riedle

Dear R users,
I have not received any help regarding my problem. The rolling window AR1 model 
returns an error if I run my code as follows:

rollingarma<-rollapply(data,width=36,function(data) 
coef(arima(data,order=c(1,0,0
Error in arima(data, order = c(1, 0, 0)) :
  non-stationary AR part from CSS

However, what is wrong with my code?

Can I use the arma() function as alternative? In this case the code is


rollingarma<-rollapply(data,width=36,function(data) 
coef(arma(data,order=c(1,0),include.intercept = FALSE)))

There were 50 or more warnings (use warnings() to see the first 50)

> warnings()

Warning messages:

1: In optim(coef, err, gr = NULL, hessian = TRUE, ...) :

  one-dimensional optimization by Nelder-Mead is unreliable:

use "Brent" or optimize() directly

In this case, I get a warning message. How can I use Brent or optimize in this 
code?

Thanks for your support.

   
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R-es] Ayuda con la homocedasticidad de Varianza

2016-06-14 Thread José Trujillo Carmona

No entiendo el problema.

¿La cuestión es saber si las distintas variables tienen la misma varianza?

No es razonables esperar que la Temperatura, la concentración o la 
profundidad tengan la misma varianza. La varianza tienen unidades y la 
varianza depende de la unidad de medida. Y no es posible expresar la 
temperatura en metros de profundidad (ni tendría sentido).


Por ejemplo la estatura, que en personas se puede distribuir entre 1.5 y 
2 metros podría estar en el orden de 0.005 m^2 a 0.007 m^2. Pero si 
medimos en cm y la estatura está desde los 150 a 200 cm, la varianza 
estaría entre 50 a 70 cm^2 (cuestión de multiplicar por 100^2) como se 
estudia en las propiedades básicas de las varianzas.


Respecto de las variables "Bioticas", supongo que son frecuencias. Pasa 
lo mismo aunque menos evidente. Aunque las frecuencias tienen siempre 
como unidad de medida los individuos (quince individuos, siete 
individuos) su distribución seguirá una distribución de Poisson o algo 
parecido; es decir que su varianza dependerá de su media; o dicho de 
otro modo, de lo abundante que sea la especie.


Si en una muestra esperamos del orden de 20 ejemplares, será fácil que 
los valores reales observados estén entre 10 y 30; pero si esperamos 
solo del orden de cinco valores la varianza no puede ser tan grande como 
en el primer caso por razones obvias (no se puede esperar que el mínimo 
esté a 10 unidades por debajo de la media, sería un número negativo de 
observaciones).


En fin. Si la pregunta es si las distintas variables tienen la misma 
varianza, no necesitas test: No pueden tenerla por la naturaleza de las 
variables.


Si esa no es la pregunta es que no la he entendido. Lo siento.

Saludos.


El 14/06/16 a las 04:01, Francisco Ruben Castaneda Rivero escribió:

Buenas Tardes. He tenido problemas al obtener la Homogenidad de varianza de
una base de datos ya que tengo 5 Variables bioticas (Especies) y 4
Abioticas. El ejemplo es la siguiente:


Especie a Especie b Especie c Especie d  Especie e Profun Conc Temp Sediment
0 2 9 14 2 72 4.8 3.5 2
26 4 13 11 0 75 2.8 2.5 1
0 10 9 8 0 59 5.4 2.7 1
0 0 15 3 0 64 8.2 2.9 2
13 5 3 10 7 61 3.9 3.1 1
31 21 13 16 5 94 2.6 3.5 3
9 6 0 11 2 53 4.6 2.9 2
2 0 0 0 1 61 5.1 3.3 1
17 7 10 14 6 68 3.9 3.4 1
0 5 26 9 0 69 10 3 2
0 8 8 6 7 57 6.5 3.3 1
14 11 13 1 0 84 3.8 3.1 2
0 0 19 0 6 53 9.4 3 2
13 0 0 9 0 83 4.4 2.5 1
4 0 10 12 0 100 6.7 2.8 1
42 20 0 3 6 84 2.8 3 3
4 0 0 0 0 96 6.4 3.1 1
21 15 33 20 0 74 4.4 2.8 3
2 5 12 16 3 79 3.1 3.6 2
0 10 14 9 0 73 5.6 3 2
8 0 0 4 6 59 4.3 3.4 1
35 10 0 9 17 54 1.9 2.8 2
6 7 1 17 10 95 2.4 2.9 3
18 12 20 7 0 64 4.3 3 1
32 26 0 23 0 97 2 3 3
24 21 0 10 5 78 2.5 3.4 2
24 17 0 25 6 85 2.1 3 3
16 3 12 20 2 92 3.4 3.3 3
11 0 7 8 0 51 6 3 2
24 37 5 18 1 99 1.9 2.9 3
Me gustaria obtener la homogeneidad de varianza por poder realizar un
Análisis de Correlacción Canónica. El problema es que al utilizar Barlet o
Levenne test no calcula los valores ya que se necesita una variable
dependiente y Factor, y al meterlo como especie a y factor abiotico no lo
calcula. En este caso yo solo quiero obtener la homogeneidad de varianza
por columna ( si se puede).


Agradeceria su pronta respuesta y Muchisimas Gracias de antemano.

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] two difficult loop

2016-06-14 Thread Jim Lemon
Hi Greg,
This is obviously a problem with the data. The first error indicates
that the sequence of integers regrange[1]:regrange[2] is too long to
be allocated. Most likely this is because one or both of the endpoints
are infinite. Maybe if you can find where the NAs are you can fix it.

Jim

On Tue, Jun 14, 2016 at 12:29 AM, greg holly  wrote:
> Hi Jim;
>
> I do apologize if bothering. I have run on the real data and here is the
> error message I got:
>
> Thanks,
>
> Greg
>
> start  end
> Error in regrange[1]:regrange[2] : result would be too long a vector
> In addition: Warning messages:
> 1: In min(x) : no non-missing arguments to min; returning Inf
> 2: In max(x) : no non-missing arguments to max; returning -Inf
>
> On Mon, Jun 13, 2016 at 10:28 AM, greg holly  wrote:
>>
>> Hi Jim;
>>
>> I do apologize if bothering. I have run on the real data and here is the
>> error message I got:
>>
>> Thanks,
>>
>> Greg
>>
>> start  end
>> Error in regrange[1]:regrange[2] : result would be too long a vector
>> In addition: Warning messages:
>> 1: In min(x) : no non-missing arguments to min; returning Inf
>> 2: In max(x) : no non-missing arguments to max; returning -Inf
>>
>>
>> On Mon, Jun 13, 2016 at 3:19 AM, Jim Lemon  wrote:
>>>
>>> Hi Greg,
>>> Okay, I have a better idea now of what you want. The problem of
>>> multiple matches is still there, but here is a start:
>>>
>>> # this data frame actually contains all the values in ref in the "reg"
>>> field
>>> map<-read.table(text="reg p rate
>>>  10276 0.700  3.867e-18
>>>  71608 0.830  4.542e-16
>>>  29220 0.430  1.948e-15
>>>  99542 0.220  1.084e-15
>>>  26441 0.880  9.675e-14
>>>  95082 0.090  7.349e-13
>>>  36169 0.480  9.715e-13
>>>  55572 0.500  9.071e-12
>>>  65255 0.300  1.688e-11
>>>  51960 0.970  1.163e-10
>>>  55652 0.388  3.750e-10
>>>  63933 0.250  9.128e-10
>>>  35170 0.720  7.355e-09
>>>  06491 0.370  1.634e-08
>>>  85508 0.470  1.057e-07
>>>  8 0.580  7.862e-07
>>>  04758 0.810  9.501e-07
>>>  06169 0.440  1.104e-06
>>>  63933 0.750  2.624e-06
>>>  41838 0.960  8.119e-06
>>>  74806 0.810  9.501e-07
>>>  92643 0.470  1.057e-07
>>>  73732 0.090  7.349e-13
>>>  82451 0.960  8.119e-06
>>>  86042 0.480  9.715e-13
>>>  93502 0.500  9.071e-12
>>>  85508 0.370  1.634e-08
>>>  95082 0.830  4.542e-16",
>>>  header=TRUE)
>>> # same as in your example
>>> ref<-read.table(text="reg1 reg2
>>>  29220 63933
>>>  26441 41838
>>>  06169 10276
>>>  74806 92643
>>>  73732 82451
>>>  86042 93502
>>>  85508 95082",
>>>  header=TRUE)
>>> # sort the "map" data frame
>>> map2<-map[order(map$reg),]
>>> # get a field for the counts
>>> ref$n<-NA
>>> # and a field for the minimum p values
>>> ref$min_p<-NA
>>> # get the number of rows in "ref"
>>> nref<-dim(ref)[1]
>>> for(i in 1:nref) {
>>>  start<-which(map2$reg==ref$reg1[i])
>>>  end<-which(map2$reg==ref$reg2[i])
>>>  cat("start",start,"end",end,"\n")
>>>  # get the range of matches
>>>  regrange<-range(c(start,end))
>>>  # convert this to a sequence spanning all matches
>>>  allreg<-regrange[1]:regrange[2]
>>>  ref$n[i]<-sum(map2$p[allreg] > 0.85)
>>>  ref$min_p[i]<-min(map2$p[allreg])
>>> }
>>>
>>> This example uses the span from the first match of "reg1" to the last
>>> match of "reg2". This may not be what you want, so let me know if
>>> there are further constraints.
>>>
>>> Jim
>>>
>>> On Mon, Jun 13, 2016 at 12:35 PM, greg holly 
>>> wrote:
>>> > Hi Bert;
>>> >
>>> > I do appreciate for this. I need check your codes on task2 tomorrow at
>>> > my
>>> > office on the real data as I have difficulty (because a technical
>>> > issue) to
>>> > remote connection. I am sure it will work well.
>>> >
>>> > I am sorry that I was not able to explain my first question. Basically
>>> >
>>> > Values in ref data represent the region of chromosome. I need choose
>>> > these
>>> > regions in map (all regions values in ref data are exist in map data in
>>> > the
>>> > first column -column map$reg). And then summing up the column "map$rate
>>> > and
>>> > count the numbers that gives >0.85. For example, consider  the first
>>> > row in
>>> > data ref. They are 29220   and  63933. After sorting the first column
>>> > in
>>> > map then summing column "map$rate" only between 29220   to  63933 in
>>> > sorted
>>> > map and cut off at >0.85. Then count how many rows in sorted map gives
>>> >>0.85. For example consider there are 38 rows between 29220   in  63933
>>> >> in sorted
>>> > map$reg and only summing first 12 of them  gives>0.85. Then my answer
>>> > is
>>> > going to be 12 for 29220   -  63933 in ref.
>>> >
>>> > Thanks I lot for your patience.
>>> >
>>> > Cheers,
>>> > Greg
>>> >
>>> > On Sun, Jun 12, 2016 at 10:35 PM, greg holly 
>>> > wrote:
>>> >
>>> >> Hi Bert;
>>> >>
>>> >> I do appreciate for this. I need check your codes on task2 tomorrow at
>>> >> my
>>> >> office on the real data as