I am using ACS data to try to create a housing cost burden variable from two different variables, OCPIP and GRPIP. I want to set those that report 0 as missing and any value greater than 30 as "Yes", and any value 1-30 as "No". Here is my dyplr/Tidyverse code:
df <- df %>%
mutate(cost_burdened = if_else(OCPIP == 0 | GRPIP == 0, NA_character_,
if_else(OCPIP < 31 | GRPIP < 31, "No", "Yes")))
I feel like I have it set up right from the way I am reading it which is if X or Y = 0, then they are missing and if X or Y is greater than 31 then they are "Yes". If I created two separate variables using the exact if_else set up for one of them (so only GRPIP or OCPIP), the code works. But when I add the | it is not working. It is setting everything as missing. When I've tried different configurations including case_when it is still not working. I am not sure why this script is not working with the two variables. What I am doing wrong or missing?
Aucun commentaire:
Enregistrer un commentaire