If I have 2 n-dimensional arrays, how do I compose them into a n+1-dimension
array?
Is there a standard R function that's something like the following, but that
gives clean errors, handles all the edge cases, etc.

abind <- function(a,b)  structure( c(a,b), dim = c(dim(a), 2) )

m1 <- array(1:6,c(2,3))
m2 <- m1 + 10
abind(m1,m2)

==>

, , 1

     [,1] [,2] [,3]
[1,]    1    3    5
[2,]    2    4    6

, , 2

     [,1] [,2] [,3]
[1,]   11   13   15
[2,]   12   14   16

Thanks,

             -s

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to