Hi I am having issues with my code-
I input the code-
library(reshape)
library(plyr)
asn12<-melt(asn1,id="DATE")
asn12<-rename(asn12, "inflation=value", "Province=variable")
head(asn12)
and keep getting the error message:
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")
I have reshape, ply and dplyr installed.
However, my ply and dplyr say
Attaching package: ‘plyr’
The following objects are masked from ‘package:reshape’:
rename, round_any
Please help
The problem is in how you are specifying the replace parameter in rename
function. The messages regarding the packages are normal... The rename
function requires a named vector.
Something like replace=c(value="inflation", variable="Province")... Possibly, you need to modify your line 4 with:
asn12<-rename(asn12, replace=c(value="inflation", variable="Province"))