Consider the following data in R:
d <- data.frame(a = c("E5","E5","E5","E5"),
b = c("011","012","013","111"))
I want to add a new column that is equal to "A5" if the first letter in column b is 0 excerpt "013". That is, I want the following table:
a b c
1 E5 011 A5
2 E5 012 A5
3 E5 013
4 E5 111
How do I do that in R?
Aucun commentaire:
Enregistrer un commentaire