+,CFtime,numeric-method {CFtime} | R Documentation |
Extend a CFtime object with additional offsets
Description
A CFtime
instance can be extended by adding additional offsets using this
operator.
Usage
## S4 method for signature 'CFtime,numeric'
e1 + e2
Arguments
e1 |
CFtime. Instance of the |
e2 |
numeric. Vector of offsets to be added to the |
Details
The resulting CFtime
instance will have its offsets in the order that they
are added, meaning that the offsets from the CFtime
instance come first and
those from the numeric vector follow. There is no reordering or removal of
duplicates. This is because the time series are usually associated with a
data set and the correspondence between the two is thus preserved, if and
only if the data sets are merged in the same order.
Note that when adding multiple vectors of offsets to a CFtime
instance, it
is more efficient to first concatenate the vectors and then do a final
addition to the CFtime
instance. So avoid CFtime(definition, calendar, e1) + CFtime(definition, calendar, e2) + CFtime(definition, calendar, e3) + ...
but rather do CFtime(definition, calendar) + c(e1, e2, e3, ...)
. It is the
responsibility of the operator to ensure that the offsets of the different
data sets are in reference to the same datum.
Note also that RNetCDF
and ncdf4
packages both return the values of the
"time" dimension as a 1-dimensional array. You have to dim(time_values) <- NULL
to de-class the array to a vector before adding offsets to an existing CFtime
instance.
Negative offsets will generate an error.
Any bounds that were set will be removed. Use bounds()
to retrieve
the bounds of the individual CFtime
instances and then set them again after
merging the two instances.
Value
A CFtime
object with offsets composed of the CFtime
instance and
the numeric vector.
Examples
e1 <- CFtime("days since 1850-01-01", "gregorian", 0:364)
e2 <- 365:729
e1 + e2