PeriodicVector-class {pcts} | R Documentation |
Class PeriodicVector
Description
Objects and methods for class PeriodicVector.
Usage
PeriodicVector(x, period = length(x))
Arguments
x |
the values for inidices from 1 to |
period |
the period, defaults to |
Details
A p
-periodic vector, X
, is such that X_{i+pk} = X_i
for any integers i,k
.
Class PeriodicVector
stores the values of X_1,\ldots,X_p
and provides indexing methods for extracting and setting its
elements.
Value
an object from class "PeriodicVector"
Objects from the Class
Objects can be created by calls of the form new("PeriodicVector", ...)
or more conveniently by using "PeriodicVector()"
.
Slots
.Data
:Object of class
"numeric"
~~period
:Object of class
"numeric"
~~
Extends
Class "numeric"
, from data part.
Class "vector"
, by class "numeric", distance 2.
Class "atomicVector"
, by class "numeric", distance 2.
Class "index"
, by class "numeric", distance 2.
Class "numLike"
, by class "numeric", distance 2.
Class "number"
, by class "numeric", distance 2.
Class "replValue"
, by class "numeric", distance 2.
Methods
"PeriodicVector"
methods are defined for "["
and
"[<-"
. Arithmetic operations just inherit the recycling rules
from "numeric"
.
- [
signature(x = "PeriodicVector", i = "ANY", j = "ANY", drop = "ANY")
: ...- [
signature(x = "PeriodicVector", i = "ANY", j = "missing", drop = "ANY")
: ...- [
signature(x = "PeriodicVector", i = "missing", j = "ANY", drop = "ANY")
: ...- [
signature(x = "PeriodicVector", i = "missing", j = "missing", drop = "ANY")
: ...- [<-
signature(x = "PeriodicVector", i = "ANY", j = "ANY", value = "ANY")
: ...- [<-
signature(x = "PeriodicVector", i = "missing", j = "ANY", value = "ANY")
: ...
Author(s)
Georgi N. Boshnakov
See Also
Examples
PeriodicVector(1:4, period = 4)
PeriodicVector(1:4) ## same
new("PeriodicVector", 1:4, period = 4)
## if period is given but x is missing, the vector is filled with NA's
PeriodicVector(period = 4)
## this throws error, since length(x) != period:
## PeriodicVector(1:3, period = 4)
## extract
x <- PeriodicVector(1:4)
x[3:12]
x[c(3, 7, 11, 15)]
# any indices in (-Inf, Inf) work
x[0]
x[-3:0]
## "[<-" works on the underling vector
x[1] <- 11; x
## modulo indexing works also in assignments:
x[5] <- 21; x
## empty index returns the underlying vector
x[]
## the recycling rule applies on assignment
x[] <- 9; x
x[] <- 1:2; x
## this gives warning, as for numeric vectors
## x[] <- 8:1
## compare:
## x <- 1:4
## x[] <- 8:1
## arithmetic works as usual:
2 * x
x + 1:4
## x + 1:3 # warning - '... a multiple ...'