[Rd] sprintf behavior (PR#9250)

Bill Dunlap bill at insightful.com
Tue Sep 26 19:12:22 CEST 2006

On Mon, 25 Sep 2006 ripley at stats.ox.ac.uk wrote:

> On Mon, 25 Sep 2006, michael.bauer at lo-res.org wrote:
> ...
> > sprintf("\p") doesn't show the backslash, this occurs with all strings that
> > start with certain letters. There is however no explanation to this behavior.
> There is: see ?Quote (and C behaves in the same way).
> > And there seems to be no way to get a guaranteed backslash in sprintf.
> "\\", see the FAQ 7.8 for example.

Splus's parser emits a warning when it sees a backslash
outside of the recognized backslash sequence.  E.g.,

  > nchar("\Backslashed?")
  [1] 12
  Warning messages:
    The initial backslash is ignored in \B -- not a recognized escape sequence.
          Use \\ to make a backslash

You might want to add that warning to R's parser.  I've
seen the error in several R packages.  E.g.,

  bayesmix/R/JAGScontrol.R:  text[4] <- "-inits.R\"\n\initialize\n"
  SciViews/svDialogs/R/fixedDlg.wxPython.R:        if (length(grep("[\.]", basename(res))) == 0)

The warning is mostly emitted when the error is benign, but it
might help get people to think about what they are typing.

Bill Dunlap
Insightful Corporation
bill at insightful dot com

 "All statements in this message represent the opinions of the author and do
 not necessarily reflect Insightful Corporation policy or position."

More information about the R-devel mailing list