Convert months mmm to numeric

Viewed 47465

I have been given a csv with a column called month as a char variable with the first three letters of the month. E.g.:

"Jan", "Feb","Mar",..."Dec"

Is there any way to convert this to a numeric representation of the month, 1 to 12, or even a type that is in a date format?

4 Answers

Just adding to the existing answers and the comment in the question:

readr::parse_date("20/DEZEMBRO/18","%d/%B/%y",locale=locale("pt"))

Results date format "2018-12-20". locale("pt") is for Portuguese, which is used in Brazil, can do "es" for Spanish, "fr" for French etc.

Related