arrays - 将矩阵合并到R中的数组

标签 arrays r matrix

如果我创建了多个矩阵,如何将它们组合成一个数组?我有8个矩阵,每个矩阵有200行和200列,我需要将它们组合成dim = 200,200,8的数组。因此,我希望每个矩阵都可以作为数组的一部分。

最佳答案

这是两个例子。您可以轻松地将其扩展到八个

# create two matricies with however many rows and columns
x <- matrix( 1:9 , 3 , 3 )
y <- matrix( 10:18 , 3 , 3 )
# look at your starting data
x
y

# store both inside an array, with the same first two dimensions,
# but now with a third dimension equal to the number of matricies
# that you are combining
z <- array( c( x , y ) , dim = c( 3 , 3 , 2 ) )

# result
z

关于arrays - 将矩阵合并到R中的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15213463/

相关文章:

python - 按列对两个不同维度的 numpy 数组进行交集

c# - 使用字符串来决定使用哪个数组 (c#)

r - 将一列分散到多列中

r - 如何在r中仅标记tmap中的一个点?

ios - 刷卡中的数组获取第一个元素

python - 从数组中删除元素

regex - R - 拆分字符向量,以便将每个唯一元素添加到新的字符向量

MATLAB多维矩阵访问

iphone - 使用 Accelerate (CLAPACK) 求解压缩列存储矩阵(在 xcode 中)?

c++ - 是否可以使用纹理内存加速矩阵乘法?