[Rd] cat, print and documentation disagree (PR#8988)

ripley at stats.ox.ac.uk ripley at stats.ox.ac.uk
Fri Jun 16 16:03:41 CEST 2006


On Thu, 15 Jun 2006, bailey at galton.uchicago.edu wrote:

> Full_Name: Paul Bailey
> Version: 2.3.1
> OS: OS X (10.4.6)
> Submission from: (NULL) (128.135.133.123)
>
>
> according to cat's help file, "'cat' converts numeric/complex vectors in 
> the same way as 'print' (and not in the same way as 'as.character' which 
> is used by the S equivalent), so 'options' '"digits"' and '"scipen"' are 
> relevant.

and it does not say that it outputs the same characters.

> But, run this (what I got after # marks)
> ------
> a <- c(0.1,.0111111111111111)
>> print(a)
> [1] 0.10000000 0.01111111
>> cat(a)
> 0.1 0.01111111>
> ------
>
> I would expect the two to make the same conversion and send the same 
> number of digits (zeros or not) to standard out, OR for the 
> documentation to point out that there are differences in that the same 
> output can lead to different things being sent to standard out.

I believe it does do it in the same way, just within a smaller print width 
(the minimum needed for that element for cat(), the minimum necessary for 
all elements of the vector in print()).  So the difference only arises 
with vectors of length > 1, and we can note that.

> I observed this same problem in Win XP with R 2.3.0

Is it a `problem'?  It is just a difference that is not explicitly 
documented, (and also not documented in this report).

-- 
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-devel mailing list