[R] how to append datasets with the same name pattern as they are created within a for loop

Daniel Malter daniel at umd.edu
Mon Aug 27 03:59:24 CEST 2012


Hi,

You can use rbind(). E.g.,

id<-rep(1:10,each=10)
x<-rnorm(100)
y<-rnorm(100)
d<-data.frame(id,x,y)
rm(id,x,y)

newdata<-data.frame()
for(i in 1:10){
newdata<-rbind(newdata,split(d,d$id)[[i]])
print(newdata)
}

The resulting data.frame "newdata" has rbind-ed all split elements of d (in
this case resulting in the original dataset "d").

HTH,
Daniel



--
View this message in context: http://r.789695.n4.nabble.com/how-to-append-datasets-with-the-same-name-pattern-as-they-are-created-within-a-for-loop-tp4641377p4641379.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list