round_limits: Round values in an array to a 'nice' nearby numbers in plots

View source: R/utility_plotting.R

round_limitsR Documentation

Round values in an array to a 'nice' nearby numbers in plots

Description

Function to round an array of values to a 'nice' nearby numbers rounded numbers. This can be useful for setting plot limits. Function returns a bounding range

Usage

round_limits(
  vals,
  lower = NA,
  upper = NA,
  log = FALSE,
  vals_round = c(1, 2, 5, 10)
)

Arguments

vals

values to be bounded in array

lower

user-defined lower limit, which overrides limit found

upper

user-defined upper limit, which overrides limit found

log

if 'log == FALSE', a linear scale is assumed. If 'log == TRUE', a log10 scale is assumed

vals_round

an array with potential rounding values, after values have been scaled by their order of magnitude. Optional values have to be on the domain '1 <= vals_round < 10'

Value

two-value array with lower and upper limit

Examples

x <- c(51, 321)
round_limits(x)
round_limits(x, lower = 0)
round_limits(x, log = TRUE)

GJMeijer/soilmech documentation built on May 22, 2022, 10:39 a.m.