[R] How to fill out some columns?

2008-04-11 Thread Jorge Velez
Dear R users, I'm working with 2 data sets which look like (for example) dx and dy in the next code: # Seed set.seed(4) # First data frame dx=matrix(rnorm(6*5),ncol=6) colnames(dx)=LETTERS[1:6] # Second data frame dy=matrix(rnorm(3*5),ncol=3) colnames(dy)=c('A','C','E') As you will notice, so

Re: [R] Problem with NA data when computing standard error

2008-04-08 Thread Jorge Velez
Hi there, Perhaps se<-function(x)sqrt(var(x,na.rm=T)/sum(!is.na(x))) object1<-as.data.frame.table(tapply(Data[Year=="1999"],list(Group[Year=="1999"],Season[Year=="1999"]),mean)) object2<-as.data.frame.table(tapply(Data[Year=="1999"],list(Group[Year=="1999"],Season[Year=="1999"]),se)) Hope this

Re: [R] how to check if a variable is preferentially present in a sample

2008-04-08 Thread Jorge Velez
Hi Tania, I think it could be. I tried a solution based on your data set using a chi-squared approach. Here is what I got: # # Data set set.seed(123) d <- data.frame(cbind(val=rnorm(1:10)^2, group=sample(LETTERS[1:5],100,repl=TRUE))) d[,"val"]<-as.numeric(as.character(d$val)) #

Re: [R] test for the variance of a normal population

2008-04-07 Thread Jorge Velez
Dear Alexandra, Perhaps you can use a different approach but I think it works: # Chi-suared CI var.ci=function(x,alpha=0.05){ n=length(x)-sum(is.na(x)) s2=var(x,na.rm=T) li=s2*(n-1)/qchisq(1-alpha/2,n-1) ls=s2*(n-1)/qchisq(alpha/2,n-1) c(li,ls) } # Example set.seed(123) y=rnorm(1000,25,2) var.c

Re: [R] how to save a chart as ps in R?

2008-03-11 Thread Jorge Velez
Hi Samuel, Sure. Ckeck ?savePlot or ?postscript. I prefer the first one. HTH JIV On Wed, Mar 12, 2008 at 12:04 AM, Samuel <[EMAIL PROTECTED]> wrote: > Hi guys, > > I remember that we had some ways to save a chart as ps file, which can be > used by latex directly. I can't find it now. Can yo

[R] Replacing text

2008-03-11 Thread Jorge Velez
Hi Luciana, Try this: yourData[,1] <- sapply(yourData[,1], function(x){ x=as.character(x) x[which(x=="Toyota2")]<-"Scion" x } ) # Example set.seed(123) x=c("Jeep","Nissan", "Toyota1", "Toyota2") y=rnorm(4) DATA=data.frame(x,y) DATA x y 1Jeep -0.56047565 2 Nissan