Re: [R] Search list of elements for a specific pattern

2012-06-22 Thread arun
e correct order by, row.names(dat3)<-1:nrow(dat3) A.K. - Original Message - From: Joshua Budman To: R-help@r-project.org Cc: Sent: Friday, June 22, 2012 12:14 PM Subject: [R] Search list of elements for a specific pattern Hi, I have a list of mutations, called "mutLis

Re: [R] Search list of elements for a specific pattern

2012-06-22 Thread arun
u 1 AluJ 2  AluJ/F(R)AM 4    AluJ/FLAM 5    AluJ/FRAM 6 AluJ/monomer 7    AluJb A.K. - Original Message - From: Joshua Budman To: R-help@r-project.org Cc: Sent: Friday, June 22, 2012 12:14 PM Subject: [R] Search list of elements for a specific pattern Hi, I have a l

Re: [R] Search list of elements for a specific pattern

2012-06-22 Thread Sarah Goslee
On Fri, Jun 22, 2012 at 12:30 PM, Joshua Budman wrote: > Hi, > Thank you very much. You are correct, it is a data frame. However, the code > below is still returning the full data frame. Do you have any suggestions? > Thanks in advance, > Josh > On 22-Jun-12, at 12:22 PM, Sarah Goslee wrote: > > A

Re: [R] Search list of elements for a specific pattern

2012-06-22 Thread Bert Gunter
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 th

Re: [R] Search list of elements for a specific pattern

2012-06-22 Thread Sarah Goslee
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

[R] Search list of elements for a specific pattern

2012-06-22 Thread Joshua Budman
Hi, I have a list of mutations, called "mutList", of the form: > head(mutList) Alu 1 AluJ 2 AluJ/F(R)AM 3AluJ/FLAM 4AluJ/FRAM 5 AluJ/monomer 6AluJb It contains about 500 elements and not all of them contain the sequence "Alu". I tried using this code: Alu<-