[R] String substitution on package install?

Jeff Gentry jgentry at jimmy.harvard.edu
Mon Apr 24 23:15:16 CEST 2006


Hello ...

I was working with some older code today that started throwing errors I'd
never seen before.  The source appears to be some sort of substition of
the text of the code on install time, I was hoping that someone might be
able to point me to what I'm doing wrong.

If I take the following function:
foo <- function() {
  test <- "This is a test"
  grep("^FOO_\\w+_OK$", test)
}

and put it in some file (say foo.R).  If I source() that file, the
function appears properly.  However, if I put that file in a package, and
do a R CMD INSTALL on that package, it appears as such:

function ()
{
    test <- "This is a test"
    grep("^FOO_\\\\\\\\\\\\\\", test)
}

The switcharoo on the text in the grep() call was the source of the
errors, btw.

I originally saw this today on a cut of R-devel from late last week, but
then did a svn up from just now and saw it again (I realize that neither
are officially R-2.3.0 but the time window was less than a few days).  I
tried it on R-2.1.1 (the only older version I had sitting around for
whatever reason) and did not see this happening.

Is this something that others can even replicate, or is it particular to
something about my setup.  And even if so, is this a case where I was
doing something wrong all along which now has gotten fixed and made my
wrong thing a Really Wrong Thing?  

Thanks
-J




More information about the R-help mailing list