[英]melt function from reshape2 package
I keep getting a message saying that "objects are masked from 'package:data.table': dcast, melt" "Error: id variables not found in data: b".我不断收到一条消息,说“对象被‘package:data.table’屏蔽了:dcast,melt”“错误:在数据中找不到 id 变量:b”。 I tried to use the :: method and hoping it would work but it's not.我尝试使用 :: 方法并希望它可以工作,但事实并非如此。 What are other solutions out there?还有哪些其他解决方案? Any inputs are appreciated!任何输入表示赞赏! Thank you!谢谢!
library(reshape2)
mdat <- reshape2::melt (data2, id = 'b')
head(mdat)
Try this, Define idvar
instead of id
:试试这个,定义idvar
而不是id
:
#Code
reshape2::melt(iris,idvar='Species')
In your case:在你的情况下:
#Code2
mdat <- reshape2::melt (data2, idvar = 'b')
We can use pivot_longer
from tidyr
as tidyr functions mostly supercede the reshape2
package functions我们可以使用pivot_longer
的tidyr
作为 tidyr 函数主要取代reshape2
包函数
library(tidyr)
pivot_longer(data2 cols = -b)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.