Given a range of values and a desired divisor, determines the rounded increment to use. Useful, for example, to determine the equally-spaced intervals to use for a figure's axes.

find_increment(x, n = NULL)

Arguments

x

A numeric vector of values.

n

An integer, the divisor. If not specified, uses the number of standard deviations instead.

Value

A named numeric value, the rounded increment to iterate over the specified number of times, with the estimated place to round to as a name.

Examples

x <- rnorm(100)
find_increment(x)
#> 0 
#> 1 
find_increment(x, 6)
#> 0 
#> 1