[R] paste tab and print

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Jan 9 09:31:09 CET 2006

On Mon, 9 Jan 2006 vincent at 7d4.com wrote:

> Dear all,
> info = paste('a', 'b', sep='\t')
> print(info , quote=F)
> doesn't produce the same result with R201 and R220
> (under Windows2000)

(There are no such versions of R, and neither is current.)

> R 2.0.1 : [1] a   b
> R 2.2.0 : [1] a\tb
> I did read the CHANGESR220 file

Did you mean CHANGES?  That is for Windows-specific changes.  You 
meed to look in the NEWS file.

> and tried also the search engine but couldn't find an answer. I 
> certainly missed the point, and apologize about that.
> So if somebody could tell me how to insert a tab inside
> strings under R.2.2.0., it would be very kind.

You have.  A tab inside a string is printed as \t (see ?print.default).
However,  cat will show you the effect

> info = paste('a', 'b', sep='\t')
> print(info)
[1] "a\tb"
> cat(info, "\n")
a       b

(if this survives emailing, or try it yourself).

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