std_dates: Parse Dates to Standard Format

View source: R/std_date.R

std_datesR Documentation

Parse Dates to Standard Format

Description

std_dates standardizes a date vector and returns a vector in Date or POSIXct format, depending on whether there is sub-daily information available in the data.

Usage

std_dates(
  x,
  force = c("none", "dt", "dttm"),
  train = TRUE,
  orders = c("mdy", "dmy", "ymd", "mdyT", "dmyT", "ymdT", "mdyR", "dmyR", "ymdR",
    "mdyr", "dmyr", "ymdr", "mdyTz", "dmyTz", "ymdTz", "Tmdyz", "Tdmyz", "Tymdz",
    "mdyRz", "dmyRz", "ymdRz", "mdyrz", "dmyrz", "ymdrz", "Tmdy", "Tdmy", "Tymd",
    "Tmdyz", "Tdmyz", "Tymdz"),
  ...
)

Arguments

x

A vector of character dates

force

Whether to force conversion to Date (force = "dt") or POSIXct (force = "dttm"). The default is no forcing (force = "none").

train

logical, default TRUE. Whether to train formats on a subset of the input vector. The result of this is that supplied orders are sorted according to performance on this training set, which commonly results in increased performance. Please note that even when train = FALSE (and exact = FALSE) guessing of the actual formats is still performed on a pseudo-random subset of the original input vector. This might result in All formats failed to parse error. See notes below.

orders

The orders to use when parsing character vector with parse_date_time()

...

Additional arguments to pass to convert_to_datetime(). These will, in turn, be passed to further methods, including excel_numeric_to_date(), parse_date_time(), and as.POSIXct().

Value

A Date or POSIXct vector


jesse-smith/coviData documentation built on Jan. 14, 2023, 11:08 a.m.