seq_rel | R Documentation |
Generate a sequence with spacing based on relative differences.
seq_rel(from, to, by)
from |
The start of the sequence. |
to |
The end of the sequence. |
by |
The relative difference between consecutive elements. |
Because the relative differences depend on whether we treat the lesser or greater term as the "reference", the function actually treats each element as the center of a bin of width by
(relative to that element).
A numeric vector of some (algorithmically-determined) length where consecutive elements are separated by consistent relative differences.
Kyle Dahlin and Kylie A. Bemis
seq
# create a sequence w/ 1e-4 relative diff spacing
x <- seq_rel(500, 505, by=1e-4)
x
# relative spacing is averaged between lesser/greater element
head(diff(x) / x[-1])
head(diff(x) / x[-length(x)])
dx <- 0.5 * ((diff(x) / x[-1]) + (diff(x) / x[-length(x)]))
dx
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.