A function to receive a number and round up or down according to the next number indicated by roundTo

round_custom(x, roundTo, dir = 1)

Arguments

x

A number to round

roundTo

number indicating to which number to round, e.g., 5 , or 10

dir

A binary indicating rounding down zero or up one

Value

rounded number

Author

theforestecologist in StackOverflow

Examples

x <- c(25, 50, 75, 125, 150, 175, 220)
roundTo <- 5
dir <- 1
round_custom(
  x,
  roundTo,
  dir
)
#> [1]  30  55  80 130 155 180 225