One way to do it is to use the 'abind' package
> NCurvas <- 10
> NumSim <- 15
> dW <- replicate(NumSim, matrix(rnorm(NCurvas * 3), NCurvas, 3),
+ simplify = FALSE)> library(abind)
> DW <- do.call(abind, c(dW, rev.along = 0))
> dim(DW)
[1] 10 3 15
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Luis Felipe Parra
Sent: Monday, 28 February 2011 10:59 AM
To: r-help
Subject: [R] Transforming list into an array
Hello. I have the following object which is a list of length NumSim with
each entry being a matrix of dimensions Ncurvas x 3:
dW
replicate(NumSim,cbind(rnorm(Ncurvas),rnorm(Ncurvas),rnorm(Ncurvas)),simplify=F)
I would like to transform it into an array of dimension Ncurvas x 3 x
NumSim. Does anybody does how to do this? or how to generate directly and
array composed of independent random nomrmal numbers of dimensions Ncurvas x
3 x NumSim.
Thank you
Felipe Parra
[[alternative HTML version deleted]]
______________________________________________
R-help at 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.