2
I have a data frame with 89000
lines and in one column appears the degree of kinship with the employee. I need to divide into 4 classes
, namely:
- Class 1 - Spouse/Children
- Class 2 - Mother/Father
- Class 3 - Brothers
- OTHERS - Other Kinship
I need to create a column in the date frame that inserts the employee’s kinship class (I need to keep the original kinship in the database). I did it with a series of ifelse
nestled, but I wonder if there is any more "elegant solution".
ifelse(base.dados$Parentesco %in% classe1, base.dados$CLASSE <- "CLASSE 1",
ifelse(base.dados$Parentesco %in% classe2, base.dados$CLASSE <- "CLASSE 2",
ifelse(base.dados$Parentesco %in% classe3, base.dados$CLASSE <- "CLASSE 3", "OUTRAS")))
Put the tags to identify the language, and try to be clearer, I couldn’t quite understand your question
– Samuel Rizzon
See if it’s clearer Samuel
– Flavio Silva
Instead of
base.dados$CLASSE <- "CLASSE 1"
do just"CLASSE 1"
. And the same for others. More exactly,base.dados$CLASSE <- ifelse(...etc...)
.– Rui Barradas