[R] stacking data.frame in a list
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Wed Sep 26 16:56:46 CEST 2001
"Danardono" <daodao99 at student.umu.se> writes:
> The expected result will be like,
> ID age.day state
> 772307 81 0
> 772307 141 0
> 772307 234 0
> 772307 321 0
> 772307 437 0
> 772307 499 0
> 772307 601 1
> 772307 689 1
> 772307 801 0
> 772307 884 99
> 772307 961 1
> 1084506 80 0
> 1084506 148 0
> 1084506 249 99
> 1084506 344 99
This seems to do it:
do.call("rbind",lapply(names(x),function(i)
cbind(ID=rep(i,nrow(x[[i]])),x[[i]])))
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list