【发布时间】:2020-08-10 05:09:42
【问题描述】:
我正在使用 tidyr 的 pivot_longer 将数据帧从宽转换为长。我希望使用所有列并在列中维护行名。较早的 melt 函数在此调用上完美运行
w1 <- reshape2::melt(w)
head(w1)
'data.frame': 900 obs. of 3 variables:
$ Var1 : Factor w/ 30 levels "muscle system process",..: 1 2 3 4 5 6 7 8 9 10 ...
$ Var2 : Factor w/ 30 levels "muscle system process",..: 1 1 1 1 1 1 1 1 1 1 ...
$ value: num NA NA NA NA NA NA NA NA NA NA ...
但是 pivot_longer 没有
w %>% pivot_longer()
Error in UseMethod("pivot_longer") :
no applicable method for 'pivot_longer' applied to an object of class "c('matrix', 'array', 'double', 'numeric')"
欢迎提出任何建议
【问题讨论】: