Skip to content
Back to formatted view

Raw Message

Message-ID: <1930216316.8287881.1462052327296.JavaMail.yahoo@mail.yahoo.com>
Date: 2016-04-30T21:38:47Z
From: Elahe chalabi
Subject: how to use AND in grepl

Hi all,

I have one factor variable in my df and I want to extract the names from it which contain both "t2" and "pd":

  'data.frame': 36919 obs. of 162 variables 
   $TE                :int 38,41,11,52,48,75,..... 
   $TR                :int 100,210,548,546,..... 
   $Command          :factor W/2229 levels "_localize_PD","_localize_tre_t2","_abdomen_t1_seq","knee_pd_t1_localize","pd_local_abdomen_t2"...

I have tried this but I did not get result: 
   
  t2pd=subset(df,grepl("t2",Command) & grepl("pd",Command))


does anyone know how to apply AND in grepl?

Thanks
Elahe