PeriodicVector-class | R Documentation |
Objects and methods for class PeriodicVector.
PeriodicVector(x, period = length(x))
x |
the values for inidices from 1 to |
period |
the period, defaults to |
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.
an object from class "PeriodicVector"
Objects can be created by calls of the form new("PeriodicVector", ...)
or more conveniently by using "PeriodicVector()"
.
.Data
:Object of class "numeric"
~~
period
:Object of class "numeric"
~~
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.
"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")
: ...
Georgi N. Boshnakov
PeriodicVector
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 ...'
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.