SOLVED: Recode variable from text to numbers

Function recode from dplyr takes separate named arguments to describe replacements (see ... description). In your case it is sufficient to change the code into:

data$variable.r<-recode(data$variable, 'strongly disagree'=0, 'disagree'=1, 'agree'=2, 'strongly agree'=3)

Here 'strongly disagree' and others are argument names, 1 and others - argument values.

4 Likes