我有一個表函數的問題。我顯然沒有使用正確的功能或沒有正確執行它。它將ContactCode列與12月份結合起來,我需要將它們分開。如何使用Table函數指定ContactCode是它自己的列?問題與表列1
Map = HeatMapCC[,c('ContactCode','Month')]
Map = table(Map$ContactCode,Map$Month)
輸出
Dec Jan
101 219 315
103 37 47
104 69 72
110 26 60
112 41 24
113 18 28
所需的輸出
ContactCodes Dec Jan
101 219 315
103 37 47
104 69 72
110 26 60
112 41 24
113 18 28
> str(Map)
'table' int [1:26, 1:2] 219 37 69 26 41 18 106 2 26 19 ...
- attr(*, "dimnames")=List of 2
..$ : chr [1:26] "101" "103" "104" "110" ...
..$ : chr [1:2] "Dec" "Jan"
我看到的東西或者是您的輸出和期望的輸出基本相同嗎? – Thomas
@Thomas,將ContactCodes設置爲rownames –
ContactCodes數據被分組到Dec列中。我需要他們分開。 – user2600629