Learn R Programming

discretes (version 0.1.0)

arithmetic: Arithmetic series

Description

Construct an arithmetic progression, with possibly infinite values. The progression is anchored at representative and extends n_left steps to the left (decreasing values) and n_right steps to the right (increasing values) with constant spacing between consecutive terms.

Usage

arithmetic(representative, spacing, ..., n_left = Inf, n_right = Inf)

Value

A numeric series (class dsct_arithmetic, inheriting from discretes).

Arguments

representative

Numeric scalar giving a known term in the progression.

spacing

Non-negative numeric scalar describing the distance between adjacent terms.

...

Reserved for future extensions; must be empty.

n_left, n_right

Non-negative counts (possibly Inf, the default) describing how many steps exist to the left and right of representative.

See Also

integers()

Examples

Run this code
arithmetic(representative = -0.6, spacing = 0.7)
arithmetic(representative = 0.6, spacing = 0.7, n_right = 0)
arithmetic(representative = 0, spacing = 2, n_left = 2, n_right = 2)

# Negative zero, resulting in `-Inf` upon inversion:
has_negative_zero(arithmetic(-0, 1))

Run the code above in your browser using DataLab