[R] Sub with and without perl=TRUE

Denham Robert Robert.Denham at nrm.qld.gov.au
Mon Feb 14 08:01:06 CET 2005


I have a problem doing substitution using sub and perl=TRUE when the
elements of x have fewer characters than the replacement string.  Let me
show you what I mean:

> sub("m","billy","m")
[1] "billy"

But using perl=TRUE, I can only return a result as long as my x:
> sub("m","billy","m",perl=TRUE)
[1] "b"

> sub("m","billy","ma",perl=TRUE)
[1] "bi"

Etc.

Is this supposed to happen like this? I couldn't see a mention of this
requirement in the help.

I am using R 2.0.1 on windows xp.

Robert




************************************************************************
The information in this e-mail together with any attachments is
intended only for the person or entity to which it is addressed
and may contain confidential and/or privileged material.
Any form of review, disclosure, modification, distribution
and/or publication of this e-mail message is prohibited.  
If you have received this message in error, you are asked to
inform the sender as quickly as possible and delete this message
and any copies of this message from your computer and/or your
computer system network.




More information about the R-help mailing list