[R] regexp problem on R 1.7.0

About this list Date view Thread view Subject view Author view Attachment view

From: Itay Furman (itayf@fhcrc.org)
Date: Wed 31 Dec 2003 - 08:21:45 EST


Message-id: <Pine.LNX.4.44.0312301311320.10722-100000@cezanne.fhcrc.org>


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@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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Thu 01 Jan 2004 - 09:21:04 EST