one way is the following: for (i in 1:50) { dd <- data.frame(x = gl(2, 1), y = rnorm(2)) assign(paste("d", i, sep = ""), dd) }
However, I would suggest to put all these data.frames in list, e.g., df.list <- lapply(1:50, function (i) data.frame(x = gl(2, 1), y = rnorm(2))) names(df.list) <- paste("d", seq_along(df.list), sep = "") I hope it helps. Best, Dimitris tedzzx wrote:
Dear R users, I want to creat a group of data frames, such as: d1<-data.frame(x=factor(),y=numeric(),...) d2<-data.frame(x=factor(),y=numeric(),...) d3<-data.frame(x=factor(),y=numeric(),...) : : d50<-data.frame(x=factor(),y=numeric()) How can I use the loop to simply my procedure? Thanks advance Ted
-- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.