I have this dataset I need to delete (Delete and Trash) everything after the name city. How can I do?
dati1<- c("a - Novara Delete", "b - Torino Trash", "c - Milano", "f - Bari")
dati2 <-data.frame(do.call(rbind, strsplit(dati1, split = " - ")))
I have tried:
c <- dati2$X2 %>% mutate(dati2$X2 = sub("\\s+[^ ]+$", "", dati2$X2))