I am trying to convert a character vector of dates (in the format: i.e. "Jan.1990") to a date vector (keeping a similar format: i.e. "Jan 1990" or "Jan.1990").
month_year <- ("Jan.1990", "Feb.1990", "Mar.1990", "Jan.1991", "Feb.1991", Mar. 1991")
I have tried using as.Date and various commands with the lubridate package but I either end up with an incorrect format or NAs.
I tried using as.Date:
df$month_year <- as.Date(df$month_year,format = "%b%Y")
This resulted in NAs.
I tried lubridate::parse_date_time2
parse_date_time2(tidy_labor$month_year, c("Jan.1990"), exact = TRUE, orders = "bY")
But the format came out as:
unknown timezone 'Jan.1990'unknown timezone 'Jan.1990' [1] "1990-01-01 GMT" "1990-01-01 GMT" "1990-01-01 GMT" "1990-01-01 GMT" "1990-02-01 GMT" "1990-02-01 GMT" "1990-02-01 GMT"
Any help would be much appreciated.