1
我怎樣才能將我的數據幀,「水果」到矩陣轉換數據幀到矩陣
> fruits
Month Apple Mango Banana
1 June 149579 36051 28124
2 July 198742 37228 30354
3 August 397145 36483 31140
4 September 329559 37101 31588
5 October 144107 35917 29444
6 November 19432 8587 5382
7 December 0 0 0
我想要個月和水果的名稱作爲基質的頭
您可以顯示預期輸出。你需要'library(reshape2); acast(melt(fruits,id.var ='Month'),variable〜Month,value.var ='value')'或者它是'as.matrix('row.names < - '(水果[-1],水果[,1]))' – akrun
你是救世主。謝謝。我正在尋找第二個答案。 – Akshit