> For example, c("dog.is.an.animal", "cat.is.an.animal", "rat.is.an. > animal"). How can I identify the common prefix is ".is.an.animal" > and delete it to give c("dog", "cat", "rat") ? foo <- c("dog.is.an.animal", "cat.is.an.animal", "rat.is.an.animal") sub(".is.an.animal", "", foo)
Being pedantic, ".is.an.animal" is a suffix not a prefix since it comes afterwards. Regards, Richie. Mathematical Sciences Unit HSL ------------------------------------------------------------------------ ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.