[R] round up a number to 10^4
jholtman at gmail.com
Tue Nov 1 21:38:26 CET 2011
Also be aware of the IEEE standard of rounding to even:
> round(61000, -4)
> round(62000, -4)
> round(65000, -4)
> round(66000, -4)
> round(76000, -4)
> round(75000, -4)
notice what 65000 rounds to and what 75000 rounds to.
On Tue, Nov 1, 2011 at 4:13 PM, Bert Gunter <gunter.berton at gene.com> wrote:
> Yes, I agree with David that this looks like an error.
> However, for fun, one might ask: what is the fewest number of R elementary
> math operations that would produce such a result -- this might be good for
> clever 6th or 7th graders, for example.
> For here, I leave this as an exercise for the reader.
> -- Bert
> On Tue, Nov 1, 2011 at 12:42 PM, David Winsemius <dwinsemius at comcast.net>wrote:
>> On Nov 1, 2011, at 1:07 PM, Wendy wrote:
>> Hi all,
>>> I have a list of numbers, e.g., X = c(60593.23, 71631.17, 75320.1), and
>>> to round them so the output is Y = c(60000, 80000, 80000).
>> Under what notion of "rounding" would that be the result?
>> I tried
>>> Y<-round(X,-4), but it gives me Y = c(60000, 70000, 80000). Do anybody
>>> how to round up a number to 10^4?
>>> Thank you in advance.
>> David Winsemius, MD
>> Heritage Laboratories
>> West Hartford, CT
>> R-help at r-project.org mailing list
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
> Bert Gunter
> Genentech Nonclinical Biostatistics
> Internal Contact Info:
> Phone: 467-7374
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
More information about the R-help