[R] Perform operations on dataframes called with paste in loops

Uwe Ligges ligges at statistik.tu-dortmund.de
Wed Nov 18 09:05:48 CET 2009



separent wrote:
> In a loop, I compose the name of a csv file using paste, then read it (e.g.,
> dataset1.csv, dataset2.csv, etc). The name of the dataframe assigned to the
> imported csv is also composed with paste (e.g., dataset1, dataset2, etc.).
> Now I want to perform operations on the dataframes dataset1, dataset2, etc.
> However, the paste function only renders a string on which I can not, for
> example, do operations like
> plot(paste("dataset",i,"[,1]",sep=""),paste("dataset",i,"[,2]",sep="")). How
> could I call the dataframe instead of the string representing its name?

1. consider to read the csv files into a *list* of dataframes and loop 
over that list.
2. if you do not want to follow 1., see ?get

Uwe Ligges




More information about the R-help mailing list