R markdown 和获取包的问题
Issues with R markdown, and getting packages
您好,我的代码有问题-
我输入验证码-
library(reshape)
library(plyr)
asn12<-melt(asn1,id="DATE")
asn12<-rename(asn12, "inflation=value", "Province=variable")
head(asn12)
并不断收到错误消息:
Error in mapvalues(x, from = names(replace), to = replace, warn_missing = warn_missing) : `from` and `to` vectors are not the same length.`
4. stop("`from` and `to` vectors are not the same length.")
3. mapvalues(x, from = names(replace), to = replace, warn_missing = warn_missing)
2. revalue(names(x), replace, warn_missing = warn_missing)
1. rename(asn12, "inflation=value", "Province=variable")
我已经安装了 reshape、ply 和 dplyr。
然而,我的 ply 和 dplyr 说
Attaching package: ‘plyr’
The following objects are masked from ‘package:reshape’:
rename, round_any
请帮忙
问题在于您如何在 rename
函数中指定替换参数。有关包的消息是正常的... rename
函数需要一个命名向量。
像 replace=c(value="inflation", variable="Province") 这样的东西...可能,您需要修改第 4 行:
asn12<-rename(asn12, replace=c(value="inflation", variable="Province"))
您好,我的代码有问题-
我输入验证码-
library(reshape)
library(plyr)
asn12<-melt(asn1,id="DATE")
asn12<-rename(asn12, "inflation=value", "Province=variable")
head(asn12)
并不断收到错误消息:
Error in mapvalues(x, from = names(replace), to = replace, warn_missing = warn_missing) : `from` and `to` vectors are not the same length.`
4. stop("`from` and `to` vectors are not the same length.")
3. mapvalues(x, from = names(replace), to = replace, warn_missing = warn_missing)
2. revalue(names(x), replace, warn_missing = warn_missing)
1. rename(asn12, "inflation=value", "Province=variable")
我已经安装了 reshape、ply 和 dplyr。
然而,我的 ply 和 dplyr 说
Attaching package: ‘plyr’
The following objects are masked from ‘package:reshape’:
rename, round_any
请帮忙
问题在于您如何在 rename
函数中指定替换参数。有关包的消息是正常的... rename
函数需要一个命名向量。
像 replace=c(value="inflation", variable="Province") 这样的东西...可能,您需要修改第 4 行:
asn12<-rename(asn12, replace=c(value="inflation", variable="Province"))