opts_Date {constructive} | R Documentation |
Constructive options class 'Date'
Description
These options will be used on objects of class 'date'.
Usage
opts_Date(
constructor = c("as.Date", "as_date", "date", "new_date", "as.Date.numeric",
"as_date.numeric", "next", "double"),
...,
origin = "1970-01-01"
)
Arguments
constructor |
String. Name of the function used to construct the object. |
... |
Additional options used by user defined constructors through the |
origin |
Origin to be used, ignored when irrelevant. |
Details
Depending on constructor
, we construct the object as follows:
-
"as.Date"
(default): We wrap a character vector withas.Date()
, if the date is infinite it cannot be converted to character and we wrap a numeric vector and provide anorigin
argument. -
"as_date"
: Similar as above but usinglubridate::as_date()
, the only difference is that we never need to supplyorigin
. -
"date"
: Similar as above but usinglubridate::date()
, it doesn't support infinite dates so we fall back onlubridate::as_date()
when we encounter them. -
"new_date"
: We wrap a numeric vector withvctrs::new_date()
-
"as.Date.numeric"
: We wrap a numeric vector withas.Date()
and use the providedorigin
-
"as_date.numeric"
: Same as above but usinglubridate::as_date()
and use the providedorigin
-
"next"
: Use the constructor for the next supported class. Call.class2()
on the object to see in which order the methods will be tried. -
"double"
: We define as an double vector and repair attributes
If the data is not appropriate for a constructor we fall back to another one appropriately.
Value
An object of class <constructive_options/constructive_options_Date>