[R] Rounding to the nearest 5

Erich Neuwirth
Mon, 17 Aug 2009 11:25:30 -0000

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