seq_rel: Relative Sequence Generation

View source: R/utils.R

seq_relR Documentation

Relative Sequence Generation

Description

Generate a sequence with spacing based on relative differences.

Usage

seq_rel(from, to, by)

Arguments

from

The start of the sequence.

to

The end of the sequence.

by

The relative difference between consecutive elements.

Details

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).

Value

A numeric vector of some (algorithmically-determined) length where consecutive elements are separated by consistent relative differences.

Author(s)

Kyle Dahlin and Kylie A. Bemis

See Also

seq

Examples

# 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

kuwisdelu/matter documentation built on Dec. 8, 2024, 8:09 p.m.