[R] split function

2010-02-26 Thread rusers.sh
Hi, I am using split function and wonder how to add the factor to the splitted results. #Example n <- 3; nn <- 10 g <- factor(round(n * stats::runif(n * nn))) #factor x <- rnorm(n * nn) + sqrt(as.numeric(g))#value xg <- split(x, g) xg $`0` [1] 0.82513702 -0.03911584 2.32955347 0.36745335

Re: [R] split function

2010-02-26 Thread rusers.sh
zes of different levels, displayed above. That is, 7 for level 0, 9 for level 1, et al. Thanks. 2010/2/26 Henrique Dallazuanna > Try this: > > split(data.frame(x, g), g) > > On Fri, Feb 26, 2010 at 3:55 PM, rusers.sh wrote: > > Hi, > > I am using split function and wonder h

Re: [R] split function

2010-02-26 Thread rusers.sh
Thanks. I think i mistake the sampling() with split(). 2010/2/26 David Winsemius > > On Feb 26, 2010, at 2:40 PM, rusers.sh wrote: > > Your method seems to only re-express the data "data.frame(x, g)" using >> another format. >> > > In all fairness to the

[R] Error--memory could not be "read"

2010-03-14 Thread rusers.sh
Hi, I wrote my own function to finish my work. One strange thing happened. If i set the number of simulations to be "10", it goes correctly. But if i set the number of simulations into "100", then errors appeared. Error information: The instruction at "0x6abf12cf" referenced memory at "0x0286fff

[R] Use a variable of a list in a loop

2010-04-07 Thread rusers.sh
Hi all, My problem may be related with the list manipulations. See below. #example data a<-list() a[[1]]<-data.frame(matrix(c(1:4),ncol=2)); a[[2]]<-data.frame(matrix(c(5:8),ncol=2)) I can use a[[1]]$X1,a[[1]]$X2,a[[2]]$X1,a[[2]]$X2 to use the corresponding variables. But what i need to do is

Re: [R] Use a variable of a list in a loop

2010-04-07 Thread rusers.sh
Cool. Using [[var]] instead of $var to extract the expected variable is really what i want. Thanks. Guys. 2010/4/7 Steve Lianoglou > Hi, > > On Wed, Apr 7, 2010 at 6:27 PM, rusers.sh wrote: > > Hi all, > > My problem may be related with the list manipulations. See bel

[R] selected observations based several variables

2010-04-07 Thread rusers.sh
Hi, My problem maybe a little bit complicated, so forgive me if the following words are too much. #date set a0<-matrix(c(1.1,1.3,1.1,1.3,1.3, 2.0,1.8,2.0,1.8,1.8, "12/01/2008","05/20/2007","12/06/2008","05/10/2007","05/06/2007", "N","N","A","C","A", 1,2,3,4,5),ncol=5,byrow=FALSE) a0<-data.frame(

[R] problem of R CMD check

2010-04-21 Thread rusers.sh
Hi all, Today, i just installed the newest R version 2.10.1 and other necessary tools for building R package under windows,e.g. Rtools, perl. All are the newest version. After the correct configuration under windows, i use it to re-check my old package. I found the following prolem when check

Re: [R] problem of R CMD check

2010-04-22 Thread rusers.sh
); flush(stdout()) ### Name: stKDE.simcomp ### Here, just copied my example codes, so i ignored here to save space. ### * ### cat("Time elapsed: ", proc.time() - get("ptime", pos = 'CheckExEnv'),"\n") grDevices::dev.off() ### ### Local variables: *** ### m

[R] probem on merge data

2009-11-05 Thread rusers.sh
Hi there, data1<-matrix(data=c(1,1.2,1.3,"3/23/2004",1,1.5,2.3,"3/22/2004",2,0.2,3.3,"4/23/2004",3,1.5,1.3,"5/22/2004"),nrow=4,ncol=4,byrow=TRUE) data1<-data.frame(data1) names(data1)<-c("areaid","x","y","date") data1 areaid x y date 1 1 1.2 1.3 3/23/2004 2 1 1.5 2.3 3/22/200

[R] Outputing multilple subsets

2009-11-08 Thread rusers.sh
Hi Rusers, I hope to divide the original dataset into several subsets and output these multilple datasets. But errors appeared in my loops. See example. ## a<-c(1:10) b<-c(rep(1,3),rep(2,3),rep(3,4)) c<-data.frame(a,b) #c is the example data num<-c(unique(b)) # I hope to get the subsets c_1.

Re: [R] Outputing multilple subsets

2009-11-09 Thread rusers.sh
c.1 Error: object 'c.1' not found > c.2 Error: object 'c.2' not found > c.3 Error: object 'c.3' not found Thanks a lot. - Jane Chang Queen's 2009/11/9 Johann Hibschman > On Nov 8, 2009, at 7:23 PM, rusers.sh wrote: > > for (i in n

Re: [R] Outputing multilple subsets

2009-11-09 Thread rusers.sh
Thanks for your ideas. They are really helpful for me to think about my question. Cheers, 2009/11/9 David Winsemius > > On Nov 9, 2009, at 8:45 AM, rusers.sh wrote: > > Hi Johann, >> Excellent. That is what i really want. A little problem is why the "c.n" >> d

[R] how to stop a loop in a sampling

2009-11-09 Thread rusers.sh
Hi, When i tried to merge two datasets (multiple to multiple merge), i met a problem on how to stop a possible loop in the sampling arguments. ###My codes are as follows.### data1<-matrix(data=c(1,1.2,1.3,"3/23/2004",1,1.5,2.3,"3/22/2004",2,0.2,3.3,"4/23/2004",3,1.5,1.3,"5/22/2004"),nrow=4,ncol=4

[R] why the same values cannot be judged to be the same in R

2009-11-12 Thread rusers.sh
Hi Rusers, I found sometimes that the same values cannot be judged to be the same in R. Anybody knows the probelm? I think i ignored some minor detail. Thanks. Here is the example. data1<-matrix(data=c(1,1.2,1.3,"3/23/2004",1,1.5,2.3,"3/22/2004",2,0.2,3.3,"4/23/2004",3,1.5,1.3,"5/22/

Re: [R] why the same values cannot be judged to be the same in R

2009-11-13 Thread rusers.sh
lso take a look at > the 'recycling' of arguments and then you may understand what is > happening: > > > data2[(data2$x1 %in% data_1$x1) & (data2$y1 %in% data_1$y1) & (data2$tag > == 0),] > areaid x1 y1 tag > 2 1 1.53 2.34 0 > 4 1 1.52

[R] Why cannot get the expected values in my function

2009-12-08 Thread rusers.sh
Hi, In the following function, i hope to save my simulated data into the "result" dataset, but why the final "result" dataset seems not to be generated. #Function simdata<-function (nsim) { result<-matrix(NA,nrow=nsim,ncol=2) colnames(result)<-c("x","y") for (i in 1:nsim) { set.seed(i) resul

Re: [R] Why cannot get the expected values in my function

2009-12-09 Thread rusers.sh
Thanks very very much. It is really not easy to change from one language to another. :) 2009/12/9 Gavin Simpson > On Tue, 2009-12-08 at 23:22 -0500, David Winsemius wrote: > > On Dec 8, 2009, at 11:07 PM, rusers.sh wrote: > > > > > Hi, > > > In the foll

[R] Confused on using expand.grid(), array(), image() and npudens(np) in my case

2009-12-13 Thread rusers.sh
Hi all, I want to use the npudens() function in the np package (multivariate kernel density estimation), but was confused by the several functions in the following codes,expand.grid(),array(),image() and npudensbw(). This confusion will only be generated in >=3 dimensions. I marked the four pla

[R] Error for making packages under windows XP-Error in library.dynam(lib, package, package.lib)

2009-12-16 Thread rusers.sh
Hi, I have installed the necessary tools for making a R package under windows and am sure these tool have been correctly configured. I am very new to try writing a package, so the error may be very obvious for you. Forgive me if it is too easy. My package name is *stam*, and i put it under the

Re: [R] Error for making packages under windows XP-Error in library.dynam(lib, package, package.lib)

2009-12-17 Thread rusers.sh
Dear Duncan, I just followed an example to try making a package. The problem is really on the useDynLib. It works after i delete it. Thanks a lot. 2009/12/17 Duncan Murdoch > rusers.sh wrote: > >> Hi, >> I have installed the necessary tools for making a R package under

[R] insert a dot to the numbers

2009-12-20 Thread rusers.sh
Hi, Anybody can give me some hints on the following problem? s<-c(110,112321) I want to insert a dot "." after the third number and get the following results. 110. 112.321 Thanks a lot. -- - Jane Chang Queen's [[alternative HTML version deleted]] _

Re: [R] insert a dot to the numbers

2009-12-21 Thread rusers.sh
Thanks a lot. 2009/12/20 Henrique Dallazuanna > Try this also: > > sapply(s, function(x)format(x, big.interval = nchar(x) - 3, big.mark = > ".")) > > On Sun, Dec 20, 2009 at 7:50 PM, rusers.sh wrote: > > Hi, > > Anybody can give me some hints on the fo

[R] checking package errors-'require' calls not declared and no visible global function definition

2009-12-24 Thread rusers.sh
Hi, I got two errors after i checking my package. The errors are as follows, Error1: * checking for unstated dependencies in R code ... WARNING 'library' or 'require' calls not declared from: boot np Error2: * checking R code for possible problems ... NOTE myfunction: no visible global functio

Re: [R] checking package errors-'require' calls not declared and no visible global function definition

2009-12-24 Thread rusers.sh
is a warning and the second is a note. You did not get > any errors. > > On Thu, Dec 24, 2009 at 9:40 PM, rusers.sh wrote: > > Hi, > > I got two errors after i checking my package. The errors are as follows, > > Error1: > > * checking for unstated dependencies i

[R] Error on checking a package with some functions ignored

2010-01-04 Thread rusers.sh
Hi, Say i have three functions in a new package, a,b and c. I only want the one function "a" to be exported for use. "b" and "c" are not very stable. If i specify to export all the three functions in the NAMESPACE file (export(a,b,c)), no errors appeared after checking the package. But if i onl

[R] Anybody can suggest a better method to build a package while ignoring some functions

2010-01-05 Thread rusers.sh
Hi, Say i have three functions in a new package, a,b and c. I only want the one function "a" to be exported for use. "b" and "c" are not very stable. If i specify to export all the three functions in the NAMESPACE file (export(a,b,c)), no errors appeared after checking the package. And i am sur

[R] "%d/%m/%Y" can not be displayed in a .rd file

2010-01-07 Thread rusers.sh
Hi all, I found the date format (e.g."%d/%m/%Y") in the .rd file cannot be displayed after building the package. See below, ###.rd file \examples{ a<-"10/20/1999" DateConversion(a,DateIn="%m/%d/%Y",DateOut="%d/%m/%Y") } The result is Examples: a<-"10-20-1999" DateConversion

Re: [R] "%d/%m/%Y" can not be displayed in a .rd file

2010-01-07 Thread rusers.sh
Solved. Thanks a lot. 2010/1/7 Duncan Murdoch > On 07/01/2010 2:09 PM, rusers.sh wrote: > >> Hi all, >> I found the date format (e.g."%d/%m/%Y") in the .rd file cannot be >> displayed after building the package. See below, >> ###.rd file >> \ex

[R] get the ranks for arrays

2010-01-18 Thread rusers.sh
Hello, 'rank' function seems to be only for vectors, but i need to get the ranks for 3-dimensional arrays. See problems below. #Example Data a1<-array(1:12,c(2,3,2)); a2<-array(2,c(2,3,2)); a3<-array(0,c(2,3,2)) > a1 , , 1 [,1] [,2] [,3] [1,]135 [2,]246 , ,

[R] problem of data manipulation

2010-01-18 Thread rusers.sh
Hello, See my problem below. a<-data.frame(c("s","c","c","n","n","n"),c(rep(1,3),rep(2,3)),c(rep(2,3),rep(1,3)),c("01/01/1999","10/02/2000","13/02/2000","11/02/2000","15/02/2000","23/02/2000")) colnames(a)<-c("var1","var2","var3","var4") > a var1 var2 var3 var4 1s1201/01/1

Re: [R] problem of data manipulation

2010-01-18 Thread rusers.sh
Thank you so much. I got it. 2010/1/18 William Dunlap > > -Original Message- > > From: Bert Gunter [mailto:gunter.ber...@gene.com] > > Sent: Monday, January 18, 2010 12:32 PM > > To: William Dunlap; 'rusers.sh'; r-help@r-project.org > > Subje

Re: [R] problem of data manipulation

2010-01-18 Thread rusers.sh
> > -Original Message- > > From: Bert Gunter [mailto:gunter.ber...@gene.com] > > Sent: Monday, January 18, 2010 12:32 PM > > To: William Dunlap; 'rusers.sh'; r-help@r-project.org > > Subject: RE: [R] problem of data manipulation > > > > Absolutely... so

[R] change codes into loops

2010-01-18 Thread rusers.sh
Hi, See example. for (i in 1:2) { for (j in 1:3) { b_1[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[1] b_2[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[2] b_3[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[3] } } The inner codes is really repeated, so i want to change the inner codes into loop

Re: [R] change codes into loops

2010-01-18 Thread rusers.sh
Winsemius > > On Jan 18, 2010, at 7:19 PM, rusers.sh wrote: > > Hi, >> See example. >> for (i in 1:2) { >> for (j in 1:3) { >>b_1[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[1] >> b_2[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[2] &g

[R] forgot the function to divide a dataset into equal parts

2010-01-19 Thread rusers.sh
Hi, I just cannot remember the R function to divide a dataset into equal parts. And i searched the "divide dataset into equal parts" in R site, but cannot find it. Anybody can tell me that function. I am just blocked by it. Thanks a lot. -- - Jane Chang Queen's [[al

Re: [R] forgot the function to divide a dataset into equal parts

2010-01-19 Thread rusers.sh
Yes. I am looking for them. Thanks. 2010/1/19 jim holtman > ?cut > ?split > > On Tue, Jan 19, 2010 at 3:18 PM, rusers.sh wrote: > > Hi, > > I just cannot remember the R function to divide a dataset into equal > > parts. And i searched the "divide dataset

[R] could we use ":" to represent multiple matrice in a list or sequential chracter names

2010-01-19 Thread rusers.sh
Hi, I know we can use 1:10 to represent the 1,2,3,...,10 numbers, but the following conditions are except. Anybody knows how to represent the following two cases with similar usage of ":" or others? Usually, i will get several hundred names for them, such as a1,a2,... or f[[1]],f[[2]],... #Exa

[R] Change an array into a dataset of four variables, dim1, dim2, dim3 and its elements

2010-01-20 Thread rusers.sh
Hi, See my example below. a<-array(1:12,c(2,3,2)) > a , , 1 [,1] [,2] [,3] [1,]135 [2,]246 , , 2 [,1] [,2] [,3] [1,]79 11 [2,]8 10 12 I want to get a result something like dim1 dim2 dim3 elements 111 121 1

[R] use same breaks and colors, but the displayed scale are different-image.plot()

2010-09-15 Thread rusers.sh
Hi all, I want to put several figures in a one figure for easy comparison, so i need to use the same methods to plot these figures. The following is an example. I also list my method, but it does not work. #Example data x<- 1:10; y<- 1:10; z<- outer( x,y,"+");z2<- outer( x,y,"-") #Quick view them

Re: [R] use same breaks and colors, but the displayed scale are different-image.plot()

2010-09-16 Thread rusers.sh
Thanks guys. I forgot to use the argument "zlim". It's solved. 2010/9/16 Jim Lemon > On 09/16/2010 12:05 PM, rusers.sh wrote: > >> Hi all, >> I want to put several figures in a one figure for easy comparison, so i >> need to use the same methods to

[R] generate random numbers from a multivariate distribution with specified correlation matrix

2010-08-23 Thread rusers.sh
Hi all, rmvnorm()can be used to generate the random numbers from a multivariate normal distribution with specified means and covariance matrix, but i want to specify the correlation matrix instead of covariance matrix for the multivariate normal distribution. Does anybody know how to generate the

Re: [R] generate random numbers from a multivariate distribution with specified correlation matrix

2010-08-23 Thread rusers.sh
similar as that. It will be better to only need us to specify the correlation matrix, mean values and possible variances. One of my aim is to simulate random fields. Thanks. 2010/8/23 Ben Bolker > rusers.sh gmail.com> writes: > > > rmvnorm()can be used to generate the rand

Re: [R] generate random numbers from a multivariate distribution with specified correlation matrix

2010-08-24 Thread rusers.sh
Great. It is more clearer for me. Thanks all. 2010/8/24 Michael Dewey > At 02:40 24/08/2010, rusers.sh wrote: > >> Hi all, >> rmvnorm()can be used to generate the random numbers from a multivariate >> normal distribution with specified means and covariance matrix, but

Re: [R] generate random numbers from a multivariate distribution with specified correlation matrix

2010-08-24 Thread rusers.sh
BTW, can you recommend a book on statistical simulations? I want to know more on how to generate random numbers from distributions, how to generate the theoretical models,... Thanks a lot. 2010/8/24 Michael Dewey > At 02:40 24/08/2010, rusers.sh wrote: > >> Hi all, >> rmvno

[R] cannot allocate vector of size 381.5 Mb

2010-08-30 Thread rusers.sh
Hi, I read some posts from the mailing list on the same problem, but it seems that i still cannot solve this problem. I only want to generate some simulated data. #Generate 2500 observations-it works without errors > coords<-as.matrix(expand.grid(seq(0,100,length.out=50), seq(0,100,length.out=50)

[R] obtain coordinates in google earth

2011-12-20 Thread rusers.sh
Hi all, Anybody has ever used R to automatically search the coordinates in GE? I searched the website, but cannot find some useful information. My addresses are not very regular, so the methods that require the strict address formats may be not good. Say my address is "kingston ontario canad

[R] readLines errors

2011-12-24 Thread rusers.sh
Hi All, I met a problem using readLines function to return the data from Google maps. readLines(url(" http://ditu.google.cn/maps/geo?q=+qianshuichong,+guichi+anhui,+CN&output=csv&key=ABQIq8Fnd_oUka-7RdS6BrD7GBTqeABoQuNTXS36G_rkiwQnKRW6GBTkns8JpKz6y6dScgB8827dlddUlg";), n=1, warn=FALSE) [1

Re: [R] readLines errors

2011-12-24 Thread rusers.sh
se Google Chrome as a default explorer? Or how can i find the possible solution for IE to return the same result as Google Chrome . Confusing. 2011/12/24 David Winsemius > > On Dec 24, 2011, at 4:12 AM, rusers.sh wrote: > > Hi All, >> I met a problem using readLines f

Re: [R] readLines errors

2011-12-24 Thread rusers.sh
suggestions or help? ÔÚ 2011Äê12ÔÂ24ÈÕ ÏÂÎç5:12£¬rusers.sh дµÀ£º > Hi All, > I met a problem using readLines function to return the data from Google > maps. > > readLines(url(" > http://ditu.google.cn/maps/geo?q=+qianshuichong,+guichi+anhui,+CN&output