如何在R ...中按列绑定数组?

时间:2017-10-16 01:43:03

标签: arrays r binding

寻找在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)))

非常感谢...

1 个答案:

答案 0 :(得分:1)

我们可以使用abind

library(abind)
res <- abind(a, b, along = 2)
attr(res, "dimnames") <- NULL
identical(res, wanted)
#[1] TRUE