In R, I have a vector containing characters:
v <- c("X412A-Y423A", "X400A-Y405B", "X499A-Y448B", "X455A-Y213A")
I want to create a vector based on this one, depending on the last character in each string (A or B), the new vector will have a different value (red or blue) such as:
vnew <- c("red","blue","blue","red")
Any help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire