I'm trying to recode values in multiple columns, which with the same coding scheme. I use code mutate_at
from this post but did not work.
My data frame is like this, and I want to recode "Neutral = 3" and "Agree = 4"
A B C
Neutral Agree Neutral
Neutral Agree Agree
Agree Neutral Neutral
My code
df %>%
mutate_at(c("A", "B", "C"), funs(as.character)) %>%
mutate_at(c("A", "B", "C"), funs(recode(.,"Neutral"=3, "Agree"=4)))
Error shows
Error in recode(A, Neutral = 3, Agree = 4) :
unused arguments (Neutral = 3, Agree = 4)
Thanks!