[R] using grepl in dplyr

Glenn Schultz glennmschultz at me.com
Tue Nov 29 19:37:29 CET 2016


Hello All,

I have a dataframe of about 1.5 million rows from this dataframe I need to filter out identifiers.  An example would be 070000-07099, AD0000-AD0999, and AL0000-AL9999, FN0000-FN9999.  I am using grepl to identify those of interest as follows:

 grepl("^[FN]|[AD]{2}", Identifier)

The above seems to work in the case of FN and AD.  However, there are 20 such identifiers and there must be a better way to do this than a long "or" statement.  Ultimately, I would like to filter these out using dplyr which I think the first step is to create a vector of TRUE/FALSE then filter on TRUE

Any Ideas are appreciated,
Glenn




More information about the R-help mailing list