I have a vector with data of the form
c("AM1-Project", "AM14-Blend", "B5-Implement", "SS10-Review")
and I would like to select only the characters until "-", so the ouptut should be
c("AM1", "AM14", "B5", "SS10")
CodePudding user response:
You could use sub
here:
x <- c("AM1-Project", "AM14-Blend", "B5-Implement", "SS10-Review")
output <- sub("-.*", "", x)
output
[1] "AM1" "AM14" "B5" "SS10"