我正在尝试使用dcast(),但我无法弄清楚为什么会出现此错误:
“错误:在输入中找不到 value.var (mpg)”。Dcast 似乎找不到我在 melt 函数中制作的 measure.vars 的“mpg”。
你们能帮帮我吗?
这是我的代码:
data("mtcars")
install.packages("reshape")
library(reshape)
install.packages("reshape2")
library(reshape2)
mdata <- melt(mtcars, id=c("gear","cyl"), measure.vars = c("mpg","hp"))
castData <- dcast(mdata, gear ~ cyl, value.var="mpg")