Trying to add just one column based on value from an existing column:
mutate(df, newcolumn = ifelse(DEST == c("JFK", "EWR", "LGA"), "NYC", DEST),
newcolumn = ifelse(DEST == c("ORD", "MDW"), "CHI", DEST))
By do this, R would ignore the first ifelse statement, which only mutate new column with rows that satisfy the second requirement.
So do I change to satisfy both requirements?
Aucun commentaire:
Enregistrer un commentaire