-1

How to round by increment larger than 1? Acctualy, I need the next "ceiling" in steps of 5. Example:

ceiling(c(2.5, 6, 9.9, 10, 11, 14, 15), inc = 5)   #not working
> 5  10  10  15  15  15  20

I tried ceiling(), round() and signif() but I could not figure it out. It's probably a repetition but my research always leads me to increments smaler than 1.

Thanks in advance!

NelsonGon
  • 13,015
  • 7
  • 27
  • 57
Pelle
  • 257
  • 2
  • 8
  • Oh, just found, that it is working the same way as rounding to specific increments smaler 1 like: `x <- c(1,5,10) ; round(x/50, digits = 1)*50` – Pelle Nov 04 '16 at 10:37

1 Answers1

0

This should work for you

a=c(2.5, 6, 9.9, 10, 11, 14, 15)
fiver=function(x)
{
  multiplier=floor(x/5)+1
  return(5*(multiplier))
}

fiver(a)

[1] 5 10 10 15 15 15 20