寻找在R中绑定以下两个数组的最智能和最短的方法。也提供了例外...
#Creating two arrays
(a <- array(c(1:9,19:27), dim = c(3,3,2)))
(b <- array(c(10:18,28:36), dim = c(3,3,2)))
#Wanted array by binding a and b
(wanted <- array(1:36, dim = c(3,6,2)))
非常感谢...
答案 0 :(得分:1)
我们可以使用abind
library(abind)
res <- abind(a, b, along = 2)
attr(res, "dimnames") <- NULL
identical(res, wanted)
#[1] TRUE