bde_parse_dates: Parse dates from strings

View source: R/utils.R

bde_parse_datesR Documentation

Parse dates from strings

Description

This function is tailored to date formats used in this package and may fail with other datasets. See Examples for formats that are supported.

Date formats

FREQUENCY FORMAT EXAMPLES
Daily / Business day DD MMMMYYYY 02 FEB2019
Monthly MMM YYYY MAR 2020
Quarterly MMM YYYY, where MMM is the first or the last month of the quarter, depending on the value of its variable OBSERVED. For the first quarter of 2020: ENE 2020, MAR 2020
Half-yearly MMM YYYY, where MMM is the first or the last month of the half-year period, depending on the value of its variable OBSERVED. For the first half of 2020: ENE 2020, JUN 2020
Annual YYYY 2020

Usage

bde_parse_dates(dates_to_parse)

Arguments

dates_to_parse

Character vector of dates to parse.

Details

Parse strings representing dates with as.Date().

Value

A vector of Date values.

See Also

as.Date()

Examples

# Supported formats.
would_parse <- c(
  "02 FEB2019", "15 ABR 1890", "MAR 2020", "ENE2020",
  "2020", "12-1993", "01-02-2014", "01/02/1990"
)

parsed_ok <- bde_parse_dates(would_parse)

class(parsed_ok)

tibble::tibble(raw = would_parse, parsed = parsed_ok)

# Unsupported formats.

wont_parse <- c("JAN2001", "2010-01-12", "01 APR 2017", "01/31/1990")

parsed_fail <- bde_parse_dates(wont_parse)

class(parsed_fail)

tibble::tibble(raw = wont_parse, parsed = parsed_fail)

tidyBdE documentation built on May 21, 2026, 5:07 p.m.