Skip to content
Prev 360585 / 398503 Next

how to use AND in grepl

Thanks for your reply tom. After using  Subset(df,grepl("(.*t2.*pd.*)|(.*pd.*t2.*)"),df$Command)  I get this error: Argument "x" is missing, with no default. Actually I don't know how to fix this. Do you have any idea?
Thanks,
Elahe
On Saturday, April 30, 2016 7:35 PM, Tom Wright <tom at maladmin.com> wrote:
Actually not sure my previous answer does what you wanted. Using your approach:
 t2pd=subset(df,grepl("t2",df$Command) & grepl("pd",df$Command))
Should work.
I think the regex pattern you are looking for is:
 Subset(df,grepl("(.* t2.*pd.* )|(.* pd.* t2.*)",df$Command)
On Sat, Apr 30, 2016, 7:07 PM Tom Wright <tom at maladmin.com> wrote:
subset(df,grepl("t2|pd",x$Command))