[R] how to subset rows using regular expression patterns

From: zhihua li <lzhtom_at_hotmail.com>
Date: Sat 03 Dec 2005 - 22:20:15 EST

hi netters,

i have a dataframe A with several columns(variables). the elements of column M are character strings. so

i wanna extract all the rows where A$M match some regular expression pattern.
for a simple example, let the pattern be just "ab", i wanna subset the rows where A$M="ab" or "abc" or "abcd" or "abXX".........

i know i can write a loop,using some regular expression pattern functions like grep row by row. but when A's size is pretty large, it's inefficient. could anyone give me a hint about a faster code?

thanks a lot!

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Dec 03 22:37:16 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:28 EST