dimanche 7 juin 2020

r why if_else converted character to numbers and how to keep character

I had character variables in my dataset and after if_else they were converted to numbers while I need them to be characters (later I will convert them to factors). Does anyone know how to fix it?

I had these lines of code

data <- data %>%
  mutate(
    flag_elevator = if_else(elevator_type == 'nincs megadva'|is.na(elevator_type), 1, 0),
    elevator_type = if_else(elevator_type == 'van', 1, 0))

Aucun commentaire:

Enregistrer un commentaire