[Rd] undesirable rounding off due to 'read.table' (PR#8974)

ripley at stats.ox.ac.uk ripley at stats.ox.ac.uk
Tue Jun 13 16:51:22 CEST 2006


I believe this to be a false report.  It is *printing* that rounds off the 
numbers, not the reading.

You provide no evidence of your assertions: here is a simple counter-example:

> A <- data.frame(a=12.4283675334551)
> write.table(A, "foo")
> AA <- read.table("foo")
> A
          a
1 12.42837
> AA
          a
1 12.42837
> print(AA, digits=16)
                  a
1 12.4283675334551
> AA-A
   a
1 0

The last just happens to be true in this example, as there would normally 
be a small representation error.

On Tue, 13 Jun 2006, overeem at knmi.nl wrote:

> Full_Name: Aart Overeem
> Version: 2.2.0

You are explicitly instructed to upgrade before reporting a bug.

> OS: Linux
> Submission from: (NULL) (145.23.254.155)
>
>
> Construct a dataframe consisting of several variables by using 
> 'data.frame' and 'cbind' and write it to a file with 'write.table'. The 
> file consists of headers and values, such as 12.4283675334551 (so 13 
> numbers behind the decimal point).

That is, 15 significant digits.

> If this dataframe is read with 'read.table(filename, skip = 1)' or 
> 'read.table(filename, header = TRUE') the values only have 7 numbers 
> behind the decimal point, e.g. 12.42837.

Your example has *five*, and is printed to 7 significant digits, the 
default for printing.

> So, the reading rounds off the values. This is not mentioned in the 
> manual. Although the values still have many numbers behind the decimal 
> point, rounding off is, in my view, never desirable.

Nor is submitting false reports.

-- 
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