I have a df that I want to switch the score in some of its columns when 5 will be 1, 4 will be 3, and so on... q_switch is a vector that contains the names of the columns in which I want to switch the score
> q_switch
[1] "E1" "E2" "E3" "E4" "E5" "E6" "E7" "E8" "E9"...
I tried to so the following as I saw in some answers:
data%\>%
mutate_at(
.vars = vars(q_switch),
.funs = funs(. = case_when(
. == 5 ~ 1
. == 4 ~ 2
. == 2 ~ 4
. == 1 ~ 5
)))
But when I'm trying to run this code but an error message pop up and says:
Error: unexpected symbol in:
" . == 5 ~ 1
."
What am I doing wrong?