[R] Problem with print() and backslashes.

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Nov 30 10:00:32 CET 2004


On Tue, 30 Nov 2004, Kevin Brinkmann wrote:

> Dear R List
>
> I have a small problem concerning the output of print().
>
> My version:
>
>> R.version
>         _
> platform i386-portbld-freebsd5.2
> arch     i386
> os       freebsd5.2
> system   i386, freebsd5.2
> status
> major    1
> minor    9.0
> year     2004
> month    04
> day      12
> language R
>
> Consider this: I want to print a backslash with an exclamation mark. Here
> is the output.
>
>> print( "\!" )
> [1] "!"
>
> Now I try it differently...
>
>> print( "\\!" )
> [1] "\\!"
>
> The output contains two backslashes. Why?

Because it is documented to escape backslashes: use cat() if that is not 
what you want.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list