pretty_range | R Documentation |
Creates an evenly spaced, pretty sequence of numbers for a range of a vector.
pretty_range(x, n = NULL, length = NULL)
x |
A numeric vector. |
n |
Numeric value, indicating the size of how many values are used to
create a pretty sequence. If |
length |
Integer value, as alternative to |
A numeric vector with a range corresponding to the minimum and
maximum values of x
. If x
is missing, a function,
pre-programmed with n
and length
is returned. See examples.
data(iris) # pretty range for vectors with decimal points pretty_range(iris$Petal.Length) # pretty range for large range, increasing by 50 pretty_range(1:1000) # increasing by 20 pretty_range(1:1000, n = 7) # return 10 intervals pretty_range(1:1000, length = 10) # same result pretty_range(1:1000, n = 2.5) # function factory range_n_5 <- pretty_range(n = 5) range_n_5(1:1000)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.