The numericSequence
class is a compact representation of a
numeric vector in an arithemetic sequence.
(numeric
) the start of the sequence.
(numeric
) the end of the sequence.
(numeric
) the increment for the sequence.
(integer
) the length of the sequence.
The numericSequence
class extends the positionsNumeric
class.
Valid numericSequence
objects must contain a single non-NA
number in
at least three of the four slots. If all four are present, the length
slot is ignored, and a warning message is generated when the sequence is used.
If length
is present and not ignored, it must
be non-negative. (A zero-length sequence is equivalent to numeric(0)
.)
Otherwise, the sign of the by
slot must agree with the sign of
(to - from)
to have a valid sequence. In particular, if by
is zero,
then to
and from
must be equal. The default sequence
(generated by calling numericSequence()
or
new("numericSequence")
) has length 0.
A numericSequence
can be coerced to numeric
or integer
using as
,
and regularly-spaced numbers can be coerced to numericSequence
using as
. This fails if the input is not a regular arithmetic
sequence within a tolerance given by timeDateOptions("ts.eps")
.
Most operations on numericSequence
objects (for example, mathematical functions,
arithmetic, comparison operators, or subscripting) work by first coercing to a numeric
vector, and therefore do not return numericSequence
objects.
numericSequence
function.