[.date_xx | R Documentation |

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 class 'date_xx' x[i] ## S3 replacement method for class 'date_yq' x[i] <- value ## S3 replacement method for class 'date_ym' x[i] <- value ## S3 replacement method for class 'date_yw' x[i] <- value ## S3 method for class 'date_xx' x[[i]] ## S3 replacement method for class 'date_yq' x[[i]] <- value ## S3 replacement method for class 'date_ym' x[[i]] <- value ## S3 replacement method for class '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

base::Extract

x <- date_yq(2016, 1:4) x[[2]] x[1] <- date_yq(2016, 3) x[2] <- 20164 # 2016, 4th quarter x[1:2] # Trying to assign illegal values for the respective date_xx type raises an error try(x[2] <- 20165) x <- date_ym(2016, 1:3) x[1] <- 201610 # October 2016 x <- date_yw(2016, 50:52) x[1] <- 201649 # 2016, week 52

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.