0

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.

  • It would be eaiser to help you if you provide [a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including a snippet of your data or some fake data. – stefan Feb 16 '22 at 18:03
  • This said: From the error message `df$Variable` is a double vector while you recode your values as integers. Hence try with converting to an integer: `recode(df$Variable, `8` = 3L, `9` = 4L, `10` = 5L, .default = as.integer(df$Variable))` – stefan Feb 16 '22 at 18:05

0 Answers0