Re: [R] Best way to remove double precision round off chaff

From: Bert Gunter <gunter.berton_at_gene.com>
Date: Sun, 13 Jun 2010 16:32:15 -0700

Jason:

Many print methods have specific options to control this: ?print.default

See also the "digits" and "scipen" settings in ?options for global control (these can be put in your startup file, for example).

See also ?format and e.g. ?sprintf for more precise control of print format.

All of this has to do with what is displayed and does not change the underlying values, of course, which round() and friends do.

Cheers,

Bert Gunter
Genentech Nonclinical Statistics

-----Original Message-----
From: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org] On Behalf Of Jason Rupert
Sent: Sunday, June 13, 2010 4:24 PM
To: R Project Help
Subject: [R] Best way to remove double precision round off chaff

I would like to get rid of the double precision round off chaff, so is the following the best way to handle it?

> 0.625-0.8+0.45-0.275

[1] -5.551115e-17
> round(0.625-0.8+0.45-0.275, digits=4)
[1] 0

Motivation for removing the chaff is for no other reason than to titty up the digits for display purposes and to help quicken the analysis of values that most definitely should be zero.

Thanks for any insights and feedback.



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 13 Jun 2010 - 23:34:44 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 Jun 2010 - 00:40:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive