parse_problems: Diagnose unparseable dates

View source: R/validate_input.R

parse_problemsR Documentation

Diagnose unparseable dates

Description

Reports which elements of a vector as_messydate() cannot represent, and why. Where as_messydate() stops at the first problem, or returns NA for text it could not read, parse_problems() inspects every element and returns one row per failure. This is intended for checking a column of dates before coercing it.

Usage

parse_problems(x)

Arguments

x

A vector of dates, usually character.

Value

A data frame with one row per problematic element and the columns index (its position in x), input (the offending value), and reason. A zero-row data frame means every element can be coerced.

Examples

parse_problems(c("2019-01-01", "2019-02-30", "2019-W12", "not a date"))
# a clean vector returns no rows
parse_problems(c("2019-01-01", "2019-01"))

messydates documentation built on Dec. 3, 2026, 5:09 p.m.