[R] Rounding to the nearest 5
Erich Neuwirth
erich.neuwirth at univie.ac.at
Mon Aug 17 13:25:30 CEST 2009
mround <- function(x,base){
base*round(x/base)
}
> mround(14,5)
[1] 15
Steve Murray wrote:
> Dear all,
>
> A hopefully simple question: how do I round a series of values (held in an object) to the nearest 5? I've checked out trunc, round, floor and ceiling, but these appear to be more tailored towards rounding decimal places.
>
> Thanks,
>
> Steve
>
>
>
> _________________________________________________________________
>
> icons.
>
> ______________________________________________
> 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.
>
>
--
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459
More information about the R-help
mailing list