Yes! I'm guessing what he wants is

mutList$Alu[grepl("Alu",mutList$Alu)]

which can be simplified using with() to

with(mutList,Alu[grepl("Alu",Alu)])

But, in the absence of dput'ted data, we can't be sure. I would also
recommend that he reads up on list or data frame syntax, depending on what
this is.

-- Bert

On Fri, Jun 22, 2012 at 9:22 AM, Sarah Goslee <sarah.goslee@gmail.com>wrote:

> 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.budman@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.
>



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

	[[alternative HTML version deleted]]

