[R] Creating dataframe names on the fly?

science! karthik.ram at gmail.com
Sat Mar 21 01:18:23 CET 2009


I am aware that it is easily possible to create var names on the fly. e.g.
assign(paste("m",i,sep=""),j)
but is it possible to assign dataframes to variables created on the fly?

e.g. 
If I have a dataframe called master and I wanted to subset parts of those
data into separate dataframes, I could do:

m1=subset(master,master$SAMPLE=='1')
m2=subset(master,master$SAMPLE=='2')
.....

but I would like to do this in a loop. Can someone give me suggestions on
how to accomplish this?


I tried assign(paste("m",i,sep=""),subset(master,master$SAMPLE==i) with no
success.


thanks! 

-- 
View this message in context: http://www.nabble.com/Creating-dataframe-names-on-the-fly--tp22631171p22631171.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list