0
我有我用熔體從reshape2並得到了下面的格式數據的收集不工作,而是融化確實爲數據轉換爲多頭形態
menthlth avedrnk2 alcday5
menthlth 1.00000000 0.07997551 0.03524646
avedrnk2 0.07997551 1.00000000 -0.02859211
alcday5 0.03524646 -0.02859211 1.00000000
形式的數據:
> melt(corr)
Var1 Var2 value
1 menthlth menthlth 1.00000000
2 avedrnk2 menthlth 0.07997551
3 alcday5 menthlth 0.03524646
4 menthlth avedrnk2 0.07997551
5 avedrnk2 avedrnk2 1.00000000
6 alcday5 avedrnk2 -0.02859211
7 menthlth alcday5 0.03524646
8 avedrnk2 alcday5 -0.02859211
9 alcday5 alcday5 1.00000000
但是當我使用它收集提供了以下錯誤:
> corr %>% gather(Var1,Var2,convert = TRUE)
Error in UseMethod("gather_") :
no applicable method for 'gather_' applied to an object of class "c('matrix', 'double', 'numeric')"
轉換爲data.frame,然後它應該工作,即'科爾%>%as.data.frame%>%gather..' – akrun
此錯誤消息是關於知識性,因爲它得到。 .. – bouncyball