> On 30 Jan 2015, at 20:34 , Evan Cooch <evan.co...@gmail.com> wrote: > > The (obvious, after the fact) solution at the bottom. D'oh... > [snip] > Forgot I was dealing with a multi-dimensional array, not a list. So, > following works fine. I'm sure there are better approaches (where 'better' is > either 'cooler', or 'more flexible'), but for the moment...) > > P <- array(0, c(2,2,2),dimnames=list(c("live","dead"),c("old","young"),NULL)) > > P[,,1] <- matrix(c(1,2,3,4),2,2,byrow=T); > P[,,2] <- matrix(c(5,6,7,8),2,2,byrow=T); > > print(P); >
Just for completeness, this also works: > P <- array(0, c(2,2,2)) > P[,,1] <- matrix(c(1,2,3,4),2,2,byrow=T); > P[,,2] <- matrix(c(5,6,7,8),2,2,byrow=T); > dimnames(P)[[1]] <- c("live","dead") > dimnames(P)[[2]] <- c("live","dead") -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd....@cbs.dk Priv: pda...@gmail.com ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.