ymon_parse: Parse a character vector as year month

Description Usage Arguments Examples

View source: R/ymon-parse.R

Description

ymon_parse() is a parser for turning character input into ymon objects. The character method for as_ymon() is very strict, and only parses input of the form "YYYY-MM", erroring on any failures. ymon_parse() is more flexible and will only issue a warning if parsing fails.

Internally:

Usage

1
ymon_parse(x, format = "%Y-%m")

Arguments

x

[character]

A character vector to coerce to ymon.

format

[character(1)]

A format to parse character input with. Should generally only consist of format tokens related to year or month. Common formats are "%Y-%m", "%b %Y", and "%Y %b".

Examples

1
2
3
4
5
ymon_parse("1970-01")
ymon_parse("1970 Jan", format = "%Y %b")

# Unparseable input results in `NA`, with a warning
try(ymon_parse(c("1970-00", "1970-01")))

DavisVaughan/datea documentation built on April 10, 2020, 12:03 a.m.