如何从矩阵中提取平行列以形成数组

时间:2019-02-03 19:58:17

标签: arrays r

我将一些表修改为excel文件,并将其转换为.csv,以练习一些基本的R数据选择。当我尝试从矩阵创建数组时,它仅输出类,而不输出原始值。我可以更改我的代码吗?

> dat1
   NumberEvents percentTotal
1        254763        100.0
2        183441         72.0
3        183190         71.9
4        137763         54.1
5        118604         46.6
6         46464         18.2
7         41544         16.3
8         41340         16.2
9         15533          6.1
10        37140         14.6
11        28390         11.1
12        12253          4.8
13            4          0.0

dat2和dat3是相似的矩阵(尺寸相同,但值不同)。

> cleanest <- array(c(dat1, dat2, dat3), c(13, 2, 3))
> cleanest
, , 1

      [,1]       [,2]      
 [1,] Numeric,13 Numeric,13
 [2,] Numeric,13 Numeric,13
 [3,] Numeric,13 Numeric,13
 [4,] Numeric,13 Numeric,13
 [5,] Numeric,13 Numeric,13
 [6,] Numeric,13 Numeric,13
 [7,] Numeric,13 Numeric,13
 [8,] Numeric,13 Numeric,13
 [9,] Numeric,13 Numeric,13
[10,] Numeric,13 Numeric,13
[11,] Numeric,13 Numeric,13
[12,] Numeric,13 Numeric,13
[13,] Numeric,13 Numeric,13

其他两个维也给出相同的结果“数字13”。

> is.array(cleanest)
[1] TRUE
> 

我期望的输出是原始值,但将是用于后续分析的数组格式。

我该怎么解决?

0 个答案:

没有答案