[Rd] Interpretation of escaped characters in \examples{}
Gordon Smyth
smyth at wehi.edu.au
Tue Jun 10 01:45:37 MEST 2003
At 05:56 PM 9/06/2003, Kurt Hornik wrote:
> > When going from the help file to rendered code, double backlashes are
> > now left as-is. Single backslashes are removed, *except* for "\b",
> > "\n", "\r" and "\f". Escaped t's, "\t" are converted to actual tabs.
>
>Going from help to rendered code means via example()? What happens
>there is that is R-ex file is *sourced*, i.e., parsed and evaluated, so
>what we see is what R does.
Fair enough. What was confusing me was that what is echoed by example() is
not exactly the same as what is in the R-ex file. I guess what happens is
that the commands are cleaned up by removing extraneous backlashes. So what
is executed by 'example()' is not necessarily identical as a string of
characters to what is in the R-ex file but is functionally equivalent to it
as an R expression.
There seems to be a separate issue with tabs in Windows, see below.
> > Is this all as it is supposed to be? The conversion of \t to <tab>
> > does seem a potential problem.
>
> > The conversion of \t to <tab> occurs in other examples of rendering
> > code also, for example:
>
> >> myfun <- function(x,pattern="\t") "hello"
> >> args(myfun)
> > function (x, pattern = " ")
>
>I cannot reproduce this: if I add
>
>f <- function(x = "\t") "hello"
>args(f)
>
>to eda/R-ex/line.R and do example("line", "eda") I get
>
>line> f <- function(x = "\t") "hello"
>
>line> args(f)
>function (x = "\t")
>NULL
>
>without the tab being expanded ...
The expansion of \t to tab may be specific to Windows. The above examples
reproduce for me in
Windows (R 1.7.0 patched or R 1.6.2) but don't reproduce in linux (R
1.7.0). The simplest example of expansion in R for Windows (R 1.7.0 patched
or R 1.6.2) is to type
"\t"
at the R prompt. This produces the printout
[1] " "
which contains an actual tab. In R 1.7.0 for linux typing
"\t"
at the R prompt prints as
[1] "\t"
as expected.
>Best
>-k
Gordon
More information about the R-devel
mailing list