round_to: Find convenient limits of input vectors

View source: R/utils_rounding.R

round_toR Documentation

Find convenient limits of input vectors

Description

If accuracy is omitted, number will be rounded to the nearest order of magnitude IE 145, if fn = min, will round to 100

Usage

round_to(
  ...,
  accuracy = NULL,
  fn = min,
  f = if (identical(fn, min)) {
     floor
 } else {
     ceiling
 },
  na.rm = TRUE
)

Arguments

...

num vectors

accuracy

number to round to; for POSIXct objects, a number of seconds

fn

fun min/max

f

rounding function: floor, ceiling or round

na.rm

a logical indicating whether missing values should be removed.

Value

num

See Also

Other rounding: magnitude_order(), magnitude_triplet(), num2str(), num2str_vec(), num_chr_suffi, size(), unit_find(), unit_modify(), unit_modify_vec(), unit_string()

Examples

round_to(runif(10, 5, 10), sample(1:10, 5))
round_to(runif(10, 5, 10), sample(1:10, 5), fn = max)
round_to(45)
round_to(145)
round_to(145, fn = max)

yogat3ch/UU documentation built on May 31, 2024, 10:14 p.m.