'Recoding a survey value in R

I have just completed some survey data in qualtrics, and I need to reassign some values in a few fields of my dataframe. I need to reassign the values for points on the scale that were assigned incorrectly, but I don't need to recode the entire scale.

Below is one of the many iterations I've tried.

recode(df$Variable, `8` = 3L, `9` = 4L, `10` = 5L, .default = df$Variable)

I can manually reassign values, but I feel like this should be a simple and easy fix.

Can anyone tell me why I keep getting this error:

error: .default must be an integer vector, not a double vector.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source