Re: [R] performing the same commands on two different data sets

2010-02-09 Thread kayj
thank you all for your help, the get() function worked perfectly. -- View this message in context: http://n4.nabble.com/performing-the-same-commands-on-two-different-data-sets-tp1474452p1474515.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] performing the same commands on two different data sets

2010-02-09 Thread Sarah Goslee
You skipped a step: the get() function allows you to use the name of an object to load the object itself. ID<-c(“D1”,”D2”) for (i in 1:length(ID)){ data<- get(ID[i]) do stuff with data } Alternatively you could write a function that takes the object as its argument. myFunction <- function

Re: [R] performing the same commands on two different data sets

2010-02-09 Thread Kjetil Halvorsen
Did you try data<-ID[[i]] instead of your data<-ID[i]? Kjetil On Tue, Feb 9, 2010 at 11:19 AM, kayj wrote: > > Hi All, > > > I would like to perform the same set of commands on the two different sets. > I would to avoid writing the same set of command twice so I was wondering if > there is an

[R] performing the same commands on two different data sets

2010-02-09 Thread kayj
Hi All, I would like to perform the same set of commands on the two different sets. I would to avoid writing the same set of command twice so I was wondering if there is an smart way to do this. I was thinking to use a loop as follows Data<-read.table(file=”data.txt”, header=T, sep=’\t’) D1<-Da