[R] Is there a way to round numbers up or down to the nearest "natural looking" number?
Uwe Ligges
ligges at statistik.tu-dortmund.de
Wed Sep 16 16:14:34 CEST 2009
round(t, -1)
Uwe Ligges
Jorgy Porgee wrote:
> Hi all,
>
> Given the following series of numbers:
>
>> t
> [1] 21.85000 30.90410 43.71000 61.82234 87.43999 123.67296
> [7] 174.91997 247.40249 349.91996 494.91815 700.00000
>
> What's the simplest way of formatting them into the nearest "natural
> looking" (rounded to nearest multiple of 10) numbers?
>
> So:
>
> t[1] becomes 20
> t[2] becomes 30
> t[3] becomes 40
> t[4] becomes 60
> t[5] becomes 90
> t[6] becomes 120, etc ?
>
> Thus far I've tried signif(t,2) but that's not working great..
>
> Any help would be much appreciated,
>
> Thanks in advance,
>
> George.
>
> ______________________________________________
> 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.
More information about the R-help
mailing list