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] -74.44069 -45.25380 -16.06691  13.11998  42.30687  71.49376 100.68065
#>  [8] 129.86754 159.05444 188.24133
seq_range(x, n = 10, trim = 0.1)
#>  [1] -3.535004 -2.122519 -0.710034  0.702451  2.114936  3.527421  4.939906
#>  [8]  6.352391  7.764876  9.177361
seq_range(x, by = 1, trim = 0.1)
#>  [1] -3.5350041 -2.5350041 -1.5350041 -0.5350041  0.4649959  1.4649959
#>  [7]  2.4649959  3.4649959  4.4649959  5.4649959  6.4649959  7.4649959
#> [13]  8.4649959

# Make pretty sequences
y <- runif (100)
seq_range(y, n = 10)
#>  [1] 0.003755821 0.113471552 0.223187284 0.332903015 0.442618746 0.552334478
#>  [7] 0.662050209 0.771765940 0.881481672 0.991197403
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.003755821 0.103755821 0.203755821 0.303755821 0.403755821 0.503755821
#>  [7] 0.603755821 0.703755821 0.803755821 0.903755821
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