On Apr 24, 2012, at 19:15 , Rui Barradas wrote: > > Has anyone realized that both 'non' and 'un' end with the same letter? The > only one we really need to check? > > (tmp <- c('mutation','nonmutated','unmutated','verymutated','other')) > > i1 <- grepl("muta", tmp) > i2 <- grepl("nmuta", tmp) > > tmp[i1 & !i2] >
Yes, I was wondering why people were avoiding the obvious use of grepl(). I'm not too happy about the "nmuta" technique though: What about "deletionmutation" and such? Might as well do the safe(r) thing: i2 <- grepl("unmuta", tmp) | grepl("nonmuta", tmp) -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd....@cbs.dk Priv: pda...@gmail.com ______________________________________________ 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.