我有不同的元素(一个类数组和一个类列表),我想组合成一个包含这两个元素的对象。我有办法在R中执行此操作吗?
数组示例:
>array
, , ind1
[,1] [,2] [,3]
[1,] 59.45412 59.41637 60.44459
[2,] 60.53659 60.84746 59.53350
[3,] 60.41962 60.26602 59.15163
, , ind2
[,1] [,2] [,3]
[1,] 60.00231 59.23779 59.53094
[2,] 58.68309 58.57091 59.66501
[3,] 60.59827 60.33224 61.53625
列表示例1:
>classifier
ID habitat
ind1 dry
ind2 wet
所需的输出:
>new_dataset
$array
, , ind1
[,1] [,2] [,3]
[1,] 59.45412 59.41637 60.44459
[2,] 60.53659 60.84746 59.53350
[3,] 60.41962 60.26602 59.15163
, , ind2
[,1] [,2] [,3]
[1,] 60.00231 59.23779 59.53094
[2,] 58.68309 58.57091 59.66501
[3,] 60.59827 60.33224 61.53625
$habitat
[1] dry wet
Levels: dry wet