[Rd] undesirable rounding off due to 'read.table' (PR#8974)
Gavin Simpson
gavin.simpson at ucl.ac.uk
Tue Jun 13 16:38:10 CEST 2006
On Tue, 2006-06-13 at 16:01 +0200, overeem at knmi.nl wrote:
> Full_Name: Aart Overeem
> Version: 2.2.0
You are asked not to report bugs on out-dated versions of R...
> 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).
> 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. 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.
Works for me in R 2.3.1 (patched)
Are you mistaking the printed representation of your data.frame for the
real thing. E.g.:
# dummy data
dat <- as.data.frame(matrix(rnorm(100)+ 0.000000000000012, ncol = 10))
# not that reading/writing has anything to do with this, but just to
# prove it
write.table(dat, file = "~/tmp/temp.csv", sep = ",")
dat <- read.table("~/tmp/temp.csv", sep = ",", header = TRUE)
dat
options(digits = 14)
dat
or
print(dat, digits = 14)
G
Ps. Wasn't sure about the etiquette of replying to R-bugs in recipients,
so deleted it in case this caused further work for the maintainer(s) of
the bug repository. Sorry if this isn't desirable.
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
* Note new Address, Telephone & Fax numbers from 6th April 2006 *
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson
ECRC & ENSIS [t] +44 (0)20 7679 0522
UCL Department of Geography [f] +44 (0)20 7679 0565
Pearson Building [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street [w] http://www.ucl.ac.uk/~ucfagls/cv/
London, UK. [w] http://www.ucl.ac.uk/~ucfagls/
WC1E 6BT.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-devel
mailing list