My aim is to recode my variable into another variable with an inverted value:
f1_1_recAktuell <- recode(Dat_MonatAktuell$f1_1, "1=10; 2=9; 3=8; 4=7; 5=6; 6=5; 7=4; 8=3; 9=2; 10=1")
This code has served me know for more than a year, yet out of a sudden I get this error message:
Warning message: Unreplaced values treated as NA as .x is not compatible. Please specify replacements exhaustively or supply .default
I guess there's something wrong with the data, yet I cannot find out what. The class of the variable is integer
, it has no missing values.
Does anyone know what I can do?
Thanks in advance!
The warning message is due to use of
recode
fromdplyr
(possibly the OP loaded the package?) instead of fromcar
. This happens whendplyr::recode
masks the same function incar
. We can specify the package name before the function as a remedy i.e.car::recode
Also, we can use
The warning can be reproduced with
dplyr::recode
To get the expected output, we can also use
dplyr::recode
in this way