[R] paste data

Søren Højsgaard Soren.Hojsgaard at agrsci.dk
Wed Jun 18 10:46:59 CEST 2008

You can put all dataframes into a list L, e.g.

L <- list(auto.0a, auto.0b,...)

and then do either a for-loop or use lapply. For example

for (ii in 1:length(L)){
  plot(y~x, data=L[[ii]],...)	


lapply(L, function(d) plot(y~x, data=d)

Med venlig hilsen
Søren Højsgaard

-----Oprindelig meddelelse-----
Fra: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] På vegne af Sybille Wendel
Sendt: 18. juni 2008 10:36
Til: r-help at r-project.org
Emne: [R] paste data


I need a command.
I have a lot of data in different dataframes(auto.0a, auto.0b, auto.0c, auto.5Na,...), that has similar names.

I could print the names all at once wih a loop with the command paste(), see below:


for (x in 1:length(plot))

I want to do very similar things with all the dataframes and their structure is also the same.
Is there a way to write a loop? (so that I don't have to write the same 18 times) I tried things like that:

for (x in 1:length(plot))

But it doesn't work because it just takes the character "auto.0a".

Thanks a lot for your help,
Sybille Wendel


R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list