Learn R Programming

mark (version 0.8.1)

round_by: 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)

Value

A vector of doubles of the same length of x

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

Examples

Run this code
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)
)

Run the code above in your browser using DataLab