Generate a sequence over the range of a vector

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

## Arguments

x A numeric vector 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. Optionally, trim values off the tails. trim / 2 * length(x) values are removed from each tail. Optionally, expand the range by expand * (1 + range(x) (computed after trimming). 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] -28.803534 -24.179042 -19.554550 -14.930059 -10.305567  -5.681075
#>  [7]  -1.056583   3.567909   8.192401  12.816893seq_range(x, n = 10, trim = 0.1)#>  [1] -6.5128552 -5.3138121 -4.1147689 -2.9157258 -1.7166827 -0.5176396
#>  [7]  0.6814035  1.8804466  3.0794897  4.2785328seq_range(x, by = 1, trim = 0.1)#>  [1] -6.5128552 -5.5128552 -4.5128552 -3.5128552 -2.5128552 -1.5128552
#>  [7] -0.5128552  0.4871448  1.4871448  2.4871448  3.4871448
# Make pretty sequences
y <- runif(100)
seq_range(y, n = 10)#>  [1] 0.008894111 0.117153441 0.225412771 0.333672101 0.441931431 0.550190761
#>  [7] 0.658450091 0.766709421 0.874968751 0.983228081seq_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.0seq_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.008894111 0.108894111 0.208894111 0.308894111 0.408894111 0.508894111
#>  [7] 0.608894111 0.708894111 0.808894111 0.908894111seq_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