cut.CFTime | R Documentation |
CFTime
instanceMethod for base::cut()
applied to CFTime objects.
## S3 method for class 'CFTime'
cut(x, breaks, ...)
x |
An instance of |
breaks |
A character string of a factor period (see |
... |
Ignored. |
When breaks
is one of "year", "season", "quarter", "month", "dekad", "day"
a factor is generated like by CFfactor()
.
When breaks
is a vector of character timestamps a factor is produced with a
level for every interval between timestamps. The last timestamp, therefore,
is only used to close the interval started by the pen-ultimate timestamp -
use a distant timestamp (e.g. range(x)[2]
) to ensure that all offsets to
the end of the CFTime
time series are included, if so desired. The last
timestamp will become the upper bound in the CFTime
instance that is
returned as an attribute to this function so a sensible value for the last
timestamp is advisable.
This method works similar to base::cut.POSIXt()
but there are some
differences in the arguments: for breaks
the set of options is different
and no preceding integer is allowed, labels
are always assigned using
values of breaks
, and the interval is always left-closed.
A factor with levels according to the breaks
argument, with
attributes 'period', 'era' and 'CFTime'. When breaks
is a factor
period, attribute 'period' has that value, otherwise it is '"day"'. When
breaks
is a character vector of timestamps, attribute 'CFTime' holds an
instance of CFTime
that has the same definition as x
, but with (ordered)
offsets generated from the breaks
. Attribute 'era' is always -1.
CFfactor()
produces a factor for several fixed periods, including
for eras.
x <- CFtime("days since 2021-01-01", "365_day", 0:729)
breaks <- c("2022-02-01", "2021-12-01", "2023-01-01")
cut(x, breaks)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.