[R] Regexp subexpression

Dieter Menne dieter.menne at menne-biomed.de
Sun Mar 26 11:00:39 CEST 2006


Gabor Grothendiek wrote:

> > read.table(textConnection(sub(pat, '"\\1" "\\2"', patid)), as.is = TRUE)
>     V1  V2
> 1 ALAN 334
> 2  AzD  44
> 3       NA


Looks like you are suffering from a creativity push. I like that one, with no 
success I had tried the variant

sub(pat, c("\\1", "\\2"') patid))

before. But anyway, I think that is is rather counter-intuitive that on has to 
use a sub(stitute) where you really want an extended strsplit.

Dieter




More information about the R-help mailing list