I am trying this code and figuring out why in the second instance I am not getting the month of the Date.
event_text <- c("7-May","Aug-89")
month(strptime(event_text[1], format = "%d-%b"))
5 #fine
month(strptime(event_text[2], format = "%b-%y"))
NA #not fine
We can use month.abb
and some regex:
> months <- gsub("\\d+|\\-", "", event_text)
> which(month.abb %in% months)
[1] 5 8
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments