[R] regexp problem on R 1.7.0

Itay Furman itayf at fhcrc.org
Tue Dec 30 22:21:45 CET 2003


Hi,

Am I missing something in using regexps in R?
Below, 'egrep' means invokation of the command from the shell 
prompt.

# I have
> as.character(block.dist.vals)
[1] "1e+06" "2e+06" "5e+06"
# that I wish to convert to:  "1" "2" "5"

# OK (R and egrep)
> sub( "e.+06", "", as.character(block.dist.vals) )
[1] "1" "2" "5"
# OK (R), egrep will *not* match pattern
> sub( "e\\+06", "", as.character(block.dist.vals) )
[1] "1" "2" "5"

# egrep will match pattern; R will not.
> sub( "e\+06", "", as.character(block.dist.vals) )
[1] "1e+06" "2e+06" "5e+06"

As-far-as I can tell the last attempt should have worked, too.
Could someone explain to me why it doesn't?

I have R 1.7.0 on RedHat 9.

Thanks in advance,
	Itay Furman

=========================================================================
            			Fred Hutchinson Cancer Research Center
email: itayf at fhcrc.org		1100 Fairview Avenue N., Mailstop D4-100
phone: +1 (206) 667 5921	P.O. Box 19024
fax:   +1 (206) 667 2917	Seattle, WA  98109-1024




More information about the R-help mailing list