round_to: Round to

round_toR Documentation

Round to

Description

round, floor, or ceiling numerics to nearest multiple of to.

Usage

round_to(x, to = 1, FUN = round)

ceiling_to(x, to = 1, FUN = ceiling)

floor_to(x, to = 1, FUN = floor)

Arguments

x

a numeric vector

to

nearest fraction or integer

FUN

a function to perform rounding

See Also

roundr; Round

Examples

x <- 1:20 / 10
cbind(
  x,
  round = round_to(x, 1),
  floor = floor_to(x, 1),
  ceiling = ceiling_to(x, 1)
)
cbind(
  x,
  round = round_to(x, 0.5),
  floor = floor_to(x, 0.5),
  ceiling = ceiling_to(x, 0.5)
)


raredd/rawr documentation built on March 4, 2024, 1:36 a.m.