I have run into a recurring issue when using the car package recode function. If I recreate a publicly used example (http://susanejohnston.wordpress.com/2012/07/18/find-and-replace-in-r-part-1-recode-in-the-library-car/)
and do:
y <- sample(c("Perch", "Goby", "Trout", "Salmon"), size = 10, replace = T)
y1 <- recode(y, "c("Perch", "Goby") = "Perciform" ; c("Trout", "Salmon") = "Salmonid"")
It returns:
Error: unexpected symbol in "y1 <- recode(y, "c("Perch"
I am running R 3.1.0 and using car_2.0-22
I assume that the author of the page was able to complete their action posted, but I can't recreate it and it is the same issue I have in my data. Thoughts?
I was the author of the wordpress document - code is wrong and thanks for flagging the issue.
Problem is that car::recode syntax requires a single quote rather than a double quote (or see comment from @MrFlick below on other acceptable syntax).
Should work.