[R] Regexp subexpression

Dieter Menne dieter.menne at menne-biomed.de
Sat Mar 25 19:04:44 CET 2006


Gabor Grothendieck <ggrothendieck <at> gmail.com> writes:

> 
> We could use sapply to reduce it slightly:
> 
> result <- sapply(sprintf("\\%d", 1:2), sub, pattern = pat, x = patid)
> result[regexpr(pat, patid) < 0,] <- NA
> 

Looks like we should make a generalized wrapper for it.

Dieter




More information about the R-help mailing list