Message-ID: <x2y8gjn247.fsf@biostat.ku.dk>
Date: 2004-11-30T08:59:52Z
From: Peter Dalgaard
Subject: Problem with print() and backslashes.
In-Reply-To: <Pine.LNX.4.53.0411300934510.11919@mp71.material.physik.uni-goettingen.de>
Kevin Brinkmann <kbrinkm at ump.gwdg.de> writes:
> 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?
(Didn't we do that one only yesterday?)
The answer is: For the same reason that you need them on input. R
likes to line things up in columns when printing vectors so cannot
just print special characters like newline, carriage return, etc.
Instead it represents them as \n, \r just like on input. To
distinguish from backslash-followed-by-n the backslash is itself
escaped with a backslash. Use cat() to output a string as raw
characters.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907