window {pcts} | R Documentation |
Periodic methods for base R functions
Description
Periodic methods for base R functions.
Usage
## S3 method for class 'PeriodicTS'
window(x, start = NULL, end = NULL, seasons = NULL, ...)
## S3 method for class 'PeriodicMTS'
window(x, start = NULL, end = NULL, seasons = NULL, ...)
## S3 method for class 'PeriodicTS'
na.trim(object, sides = c("both", "left", "right"), ...)
## S3 method for class 'PeriodicMTS'
na.trim(object, sides = c("both", "left", "right"),
is.na = c("any", "all"), ...)
## S3 method for class 'PeriodicTimeSeries'
frequency(x, ...)
## S3 method for class 'PeriodicTimeSeries'
deltat(x, ...)
## S3 method for class 'PeriodicTimeSeries'
cycle(x, ...)
## S3 method for class 'PeriodicTimeSeries'
time(x, offset = 0, ...)
## S3 method for class 'Cyclic'
start(x, ...)
## S3 method for class 'Cyclic'
end(x, ...)
Arguments
x , object |
an object from the indicated periodic class. |
start |
|
end |
|
seasons |
numeric, a subset of |
... |
Not used by these methods. |
sides |
which side to trim: start ( |
is.na |
for multivariate time series: if |
offset |
currently ignored (:TODO:) |
Details
Periodic methods for base R and other common functions for manipulation of time series. These methods work analogoulsly to their base R cousins and only the differences, if any, are discussed below.
window
takes a part of x
, preserving the
class of the object. Argument seasons
selects a subset of the
seasons.
na.trim
is a function defined in package zoo
and re-exported by pcts. It trims NA
s from one or both
ends of the time series, as requested by the arguments. The arguments
of the methods defined by pcts have the same meaning as those in
zoo.
Value
for window
and na.trim
,
an object from the same class as the original, representing the
requested part of the time series.
for frequency
, an integer number.
for deltat
, a number (1/frequency).
for cycle
and time
, a "PeriodicTS"
object.
for start
and end
, time of first/last observation,
encoded as a pair of numbers.
See Also
window
,
frequency
,
na.trim
for details on what these functions do.
availStart
and availEnd
give the times of
the first and last non-NA observations.
Examples
pres <- pcts(presidents)
head(pres, 8)
availStart(pres)
tail(pres, 12)
availEnd(pres)
## Q3 and Q4 only
presQ3Q4 <- window(pres, seasons = 3:4)
head(presQ3Q4)
identical(na.trim(pres),
window(pres, start = availStart(pres), end = availEnd(pres)))
## TRUE