R - 组合 3D 矩阵和单个向量,然后选择特定月份的数据
我现在有一个日期向量A
(362行),我有一个3D矩阵B
(尺寸360*180*3620
)
> str(ssta_date)
POSIXlt[1:362], format: "1981-11-15" "1981-12-15" "1982-01-15" "1982-02-15" "1982-03-15" ...
> dim(ssta_sst)
[1] 360 180 362
是可以将 A
和 B
组合为数据框或其他内容。它必须与 B
[,,362] 中的每个日期和每个温度相匹配。所以每个日期都会对应一个360*180的矩阵。
因为我计划执行此操作来选择某些月份数据,所以是否有任何快捷方式可以在不合并两个数据集的情况下进行月份数据选择?
i am now having a single date vector A
(362 rows) and i have a 3D matrix B
(dimensions 360*180*3620
)
> str(ssta_date)
POSIXlt[1:362], format: "1981-11-15" "1981-12-15" "1982-01-15" "1982-02-15" "1982-03-15" ...
> dim(ssta_sst)
[1] 360 180 362
is it possible to combine A
and B
as a data frame or something else. it must match each date and each temperature in the B
[,,362]. so each date will corresponding to a 360*180 matrix.
Because i am planning to do this t to select certain month data, is there any shortcut to do month data selection without combine the two data sets?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我明白你想要什么
您可以使用
melt
将数组转换为 data.frame,然后使用
merge
将其与其他数据连接起来。如果你想在末尾有一个数组,你可以使用
acast
将 data.frame 转换回数组。
If I understand what you want,
you can use
melt
to convert your array to a data.frame,and then use
merge
to join it with the other piece of data.If you want an array at the end, you can use
acast
to convert the data.frame back to an array.