Stolen from here

seq_range(x, n, by, trim = NULL, expand = NULL, pretty = FALSE)

Arguments

x

A numeric vector

n, by

Specify the output sequence either by supplying the length of the sequence with n, or the spacing between value with by. Specifying both is an error.

I recommend that you name these arguments in order to make it clear to the reader.

trim

Optionally, trim values off the tails. trim / 2 * length(x) values are removed from each tail.

expand

Optionally, expand the range by expand * (1 + range(x) (computed after trimming).

pretty

If TRUE, will generate a pretty sequence. If n is supplied, this will use pretty() instead of seq(). If by is supplied, it will round the first value to a multiple of by.

Examples

x <- rcauchy(100)
seq_range(x, n = 10)
#>  [1] -19.848696 -10.276227  -0.703758   8.868711  18.441180  28.013649
#>  [7]  37.586118  47.158587  56.731055  66.303524
seq_range(x, n = 10, trim = 0.1)
#>  [1] -3.2910771 -1.9056950 -0.5203130  0.8650691  2.2504511  3.6358331
#>  [7]  5.0212152  6.4065972  7.7919792  9.1773613
seq_range(x, by = 1, trim = 0.1)
#>  [1] -3.2910771 -2.2910771 -1.2910771 -0.2910771  0.7089229  1.7089229
#>  [7]  2.7089229  3.7089229  4.7089229  5.7089229  6.7089229  7.7089229
#> [13]  8.7089229

# Make pretty sequences
y <- runif (100)
seq_range(y, n = 10)
#>  [1] 0.001844012 0.112403835 0.222963657 0.333523479 0.444083301 0.554643123
#>  [7] 0.665202946 0.775762768 0.886322590 0.996882412
seq_range(y, n = 10, pretty = TRUE)
#>  [1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
seq_range(y, n = 10, expand = 0.5, pretty = TRUE)
#>  [1] -0.4 -0.2  0.0  0.2  0.4  0.6  0.8  1.0  1.2  1.4

seq_range(y, by = 0.1)
#>  [1] 0.001844012 0.101844012 0.201844012 0.301844012 0.401844012 0.501844012
#>  [7] 0.601844012 0.701844012 0.801844012 0.901844012
seq_range(y, by = 0.1, pretty = TRUE)
#>  [1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0