Works exactly like subsetting base vectors via [
, but preserves the
date_xx
class and subclasses. The replacement functions [<-
and [[<-
conduct additional checks before assignment to prevent the generation of
degenerate date_xx vectors (see examples).
# S3 method for date_xx [(x, i) # S3 method for date_yq [(x, i) <- value # S3 method for date_ym [(x, i) <- value # S3 method for date_yw [(x, i) <- value # S3 method for date_xx [[(x, i) # S3 method for date_yq [[(x, i) <- value # S3 method for date_ym [[(x, i) <- value # S3 method for date_yw [[(x, i) <- value
x | object from which to extract element(s) or in which to replace element(s). |
---|---|
i | indices specifying elements to extract or replace. Indices are
For When indexing arrays by An index value of |
value | A vector of the same class as |
a date_xx
vector
#> [1] "2016-Q2"#> [1] "2016-Q3" "2016-Q4"# Trying to assign illegal values for the respective date_xx type raises an error try(x[2] <- 20165)#> Error : 'value' is not a valid date_yq (yyyyq)