I want to create a new variable with a certain value when two other variables: CountryOfOrigin and CountryOfBirth are identical. I use Variable-Conditional Compute-Multiple.
IF
PAIS_NACIM == PAIS_PROC_DEST
THEN
"País de procedencia"
I always get the following error
n argument: `LugarNacimiento = ifelse(PAIS_NACIM == PAIS_PROC_DEST,
"País de procedencia", NA)`.
Caused by error in `Ops.factor()`:
! level sets of factors are different
Thank you for any comment.
Having trouble with ifelse and factors in R! Ever get the "level sets of factors are different" error? I did! It happened when I tried to conditionally assign a string based on factor values. The fix? Convert both sides to characters first! LugarNacimiento = ifelse(PAIS_NACIM == PAIS_PROC_DEST, as.character("País de procedencia"), NA_character_). Anyway, back to playing Basket Random .