Make axis labels that are numeric but should only integer values

int_breaks(n = 5, ...)

Arguments

n

integer giving the desired number of intervals. Non-integer values are rounded down. (passed to base::pretty)

...

further arguments passed to base::pretty

Value

a vector or axis labels of length n

Examples

int_breaks(n=3)(c(1,4,5,6,7,10))
#> [1]  0  5 10
int_breaks(n=6)(c(1.1,4.9,5.8,6,7,10.78))
#> [1]  0  2  4  6  8 10 12
# or pass to ggplot2: ggplot2::scale_x_continuous(breaks = int_breaks(n = 4))