I have a variable of code names and some means in it. I want to create a new variable called 'occupation' that takes code names L01, L02, and L03 and calls them 'skipper', then takes L04, and L05 and calls them 'government', then take the 'mean' values and keeps them as 'mean'. I have tried playing around with if and if_else, but I am not super familiar with how to do this.
Currently, my code name data looks like this:
Analysis$Code_Name [1] "L01" "L02" "L03" "L04" "L05" "mean" "mean" "mean" "mean"
Ideally, I would have my new occupation variable looking like this:
Analysis$Occupation [1] "skipper" "skipper" "skipper" "government" "government" "government" "mean" "mean" "mean"
Any help with how to proceed with an ifelse two conditional statement or a nested if statement would be really helpful.
Aucun commentaire:
Enregistrer un commentaire