Automatically calculate breaks for a number
find_breaks(n, breaks = 4, snap = 1, ceiling = FALSE)
a number to calcluate breaks for
the maximum number of segments you want to have
the number defining where to snap to the nearest factor
if TRUE
, n is included in the breaks
a vector of integers
# find four breaks from 1 to 100
find_breaks(100)
#> [1] 1 26 51 76
# find four breaks from 1 to 123, rounding to the nearest 20
find_breaks(123, snap = 20)
#> [1] 1 41 81 121
# note that there are only three breaks here because of the rounding
find_breaks(123, snap = 25)
#> [1] 1 51 101
# Include the value itself
find_breaks(123, snap = 25, ceiling = TRUE)
#> [1] 1 51 101 123