round_by: Rounding by a specific interval.

View source: R/round-by.R

round_byR Documentation

Rounding by a specific interval.

Description

Rounds a number or vector of numbers by another

Usage

round_by(x, by = 1, method = c("round", "ceiling", "floor"), include0 = TRUE)

Arguments

x

A number or vector to round.

by

The number by which to round

method

An option to explicitly specify automatic rounding, ceiling, or floor

include0

If FALSE replaces 0 with by

Value

A vector of doubles of the same length of x

Examples

x <- seq(1, 13, by = 4/3)

cbind(
  x,
  by_1 = round_by(x, 1),
  by_2 = round_by(x, 2),
  by_3 = round_by(x, 3)
)

mark documentation built on May 29, 2024, 5:13 a.m.