[R] Search list of elements for a specific pattern

Sarah Goslee sarah.goslee at gmail.com
Fri Jun 22 18:36:26 CEST 2012


On Fri, Jun 22, 2012 at 12:30 PM, Joshua Budman <josh.budman at gmail.com> 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:
>
> Alu<-mutList[grepl("Alu",mutList)]

Ah, a data frame. We need to know that. Since you want to search a
specific column for "Alu", you need to tell R that.

Alu <- mutList[grep("Alu", mutList$Alu), ]

more likely, but in the absence of data provided with dput() I can't
test it. Please do read the posting guide.

Sarah

-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list