What is R's multidimensional equivalent of rbind and cbind?

前端 未结 1 567
天命终不由人
天命终不由人 2020-12-25 09:46

When working with matrices in R, one can put them side-by-side or stack them top of each other using cbind and rbind, respectively. What is the equivalent function for stack

相关标签:
1条回答
  • 2020-12-25 10:36

    See the abind package. If you want them to bind on a 3rd dimension, do this:

    library(abind)
    abind(x, y, along = 3)
    

    See ?abind

    Also, abind gives a lot more convenience, but for simple binding you can just manipulate the values directly, based on the default ordering:

    array(c(x, y), dim = c(2, 2, 2))
    
    0 讨论(0)
提交回复
热议问题