Tidyverse has the fabulous Readr and it has a wide variety of parse commands, such as parse_date
, parse_*
, parse_factor
and guess_parser
. I have a custom month-year
format like the below in terms of Roman numerals such that
> emptyOffices$Month
[1] " II/90" " I/91" " II/91" " I/92" " II/92" " I/93" " II/93"
> guess_parser(emptyOffices$Month)
[1] "character"
where I
stands for January, II
stands for February and so no. For example, II/90
stands for February 1990
. The guess_parser
guess the meaning of the month-year wrong. Perhaps, there is a tool by which I can define months to help the parser to understand this?
Does there exist some tool in some Tidyverse package to read custom dates like with Roman numerals?
There must be better tidy solution, but this one works:
Or you can simply do this:
Use
as.roman
fromutils
to transform object into classroman
, turn this object into numeric string and extract month frombase
month.abb
.