简体   繁体   English

R:在同一阵列中存储不同大小的矩阵?

[英]R: store different size of matrices in same array?

I am wondering if it is possible to store different size of matrices in same array. 我想知道是否可以在同一数组中存储不同大小的矩阵。 I'm organizing monthly data for temperature, and I encounter with matrices are different each month. 我正在整理温度的每月数据,每个月遇到的矩阵都不同。 For example, February has only 28 days but January has 31 days. 例如,二月只有28天,而一月只有31天。

Data I'm dealing with contains 8 types of data, such as temperatures. 我正在处理的数据包含8种类型的数据,例如温度。 Each day in a month, 144 data is collected, so total number of data in January is 4464, April is 4320 (30days). 一个月中的每一天每天收集144个数据,因此一月份的数据总数为4464,四月份的数据总数为4320(30天)。

I sat my array: Brianna <- array(0, dim=c(4464, 8)) 我坐在我的阵列上: Brianna <- array(0, dim=c(4464, 8))

But this will not work. 但这是行不通的。 This works only for 31-day-month, January, March, May, etc. Does anyone have suggestion to solve this problem? 该功能仅适用于每月31天,一月,三月,五月等。有人建议解决此问题吗? Or do I have to store each month in different array? 还是我必须每月将其存储在不同的阵列中?

Thank you for your help. 谢谢您的帮助。

You can have a list of matrices with different dimensions: 您可以具有不同维度的矩阵列表:

x <- matrix(1:12, 3)
y <- matrix(1:20,4)
list(x,y)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM