[R] create an object list in a loop
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Mon Oct 28 15:43:57 CET 2002
Jake Bowers <jbowers at csm.berkeley.edu> writes:
> Hi.
>
> How about:
>
> n<-10
> aval<-list()
> for(i in 1:n){
> aval[[i]]<-matrix(....)
> }
>
> Then you could access the first matrix as aval[[1]]
or,
aval <- lapply(1:n, function(i) matrix(.....))
--
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