简体   繁体   English

来自 reshape2 包的熔化函数

[英]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_longertidyr作为 tidyr 函数主要取代reshape2包函数

library(tidyr)
pivot_longer(data2 cols = -b)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从reshape2包中“恢复”熔化功能? - How to “back” melt function from reshape2 package? 时间戳上的 reshape2 熔化函数给出了 NA - reshape2 melt function on timestamps gives NAs R Shiny-如何使用“融化”功能(reshape2程序包)创建堆叠的条形图 - R Shiny - How to use the “melt” function (reshape2 package) to create a stacked barplot 如何更改reshape2包中的melt.data.frame函数将“变量”列返回到“字符”类? - How to change the melt.data.frame function in reshape2 package returned “variable” column to “character” class? 我如何使用reshape2包中的熔铸法获得以下答案 - how would I get the below answer using melt/cast from reshape2 package 使用reshape2 :: melt和reshape2 :: dcast在用户定义的函数中调用变量 - Calling variable in user-defined function with reshape2::melt and reshape2::dcast 在MatLab中有效的R中的reshape2中是否存在类似的“融化”功能? - Is there a similar function to 'melt' in reshape2 in R that works in MatLab? reshape2融化警告信息 - reshape2 melt warning message 从reshape2中的熔体输出中提取数据值 - Extract data value from the output of melt in reshape2 如何使用reshape2包中的melt()来堆叠数据的分类标签以产生多个并排的boxpot - How to use melt() from the reshape2 package to stack categorical labels of data to produce multiple side-by-side boxpots
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM