I have a set of survey data that uses Likert scale responses, coded 1-5 ('strongly disagree' to 'strongly agree'). I am trying to re-centre the scores around 0, such that -2 is 'strongly disagree' and +2 is 'strongly agree'.
An obvious way of getting there is to subtract all columns by 3, but I do not know to subtract the same number from multiple columns in one line of code, I am sure there's a way...
Example data:
likert_data <- data.frame(id=c(1:10),
a=sample(x = 1:5, size = 10,replace=T),
b=sample(x = 1:5, size = 10,replace=T),
c=sample(x = 1:5, size = 10,replace=T)
)
I could of course do something like this...
likert_data %<>%
mutate(across(c(a:c), ~case_when(. == 1 ~ as.numeric(-2),
. == 2 ~ as.numeric(-1),
. == 3 ~ as.numeric(0),
. == 4 ~ as.numeric(1),
. == 5 ~ as.numeric(2))))
... but I don't think it's very elegant.
Is there a way of subtracting columns a:c by 3? Doesn't have to be using dplyr, but would really appreciate a dplyr solution if one exists! :)