You should use grepl() instead: Alu<-mutList[grepl("Alu",mutList)]
or some variant of the above, depending on the actual structure of mutList (which might be a data frame, but doesn't appear to be a generic list). str() and dput() are both very useful for asking well-formed questions. Sarah On Fri, Jun 22, 2012 at 12:14 PM, Joshua Budman <josh.bud...@gmail.com> wrote: > Hi, > I have a list of mutations, called "mutList", of the form: > > > head(mutList) > Alu > 1 AluJ > 2 AluJ/F(R)AM > 3 AluJ/FLAM > 4 AluJ/FRAM > 5 AluJ/monomer > 6 AluJb > > It contains about 500 elements and not all of them contain the > sequence "Alu". I tried using this code: > Alu<-mutList[which(grep("Alu",mutList)==1)] > > But that simply returned all of them elements in the list. Is there a > way to modify the list such that I have only the elements containing > "Alu" in the new list? Help would be appreciated! > > Josh > > -- Sarah Goslee http://www.functionaldiversity.org ______________________________________________ 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.