I have quite a simple problem that I've not found anywhere on here.
I have date format:
times = c("Dec_2011" , "July_2011", "Dec_2010" ,"July_2010" , "Dec_2009" , "July_2009", "Dec_2008" ,
"July_2008" ,"Dec_2007" , "July_2007", "Dec_2006" , "July_2006" ,"Dec_2005" , "July_2005",
"Dec_2004" , "July_2004" ,"Dec_2003" , "July_2003", "Dec_2002" , "July_2002", "Dec_2001" ,
"July_2001", "Dec_2000" , "July_2000")
How can I get these into date format:
31-07-2000, 31-07-2001, etc...
31-12-2000, 31-12-2001, etc...
I've tried:
times <- format(as.Date(time, "%B_%Y")
times
[1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
times <- format(as.Date(time, "%B_%Y), "31-%m-%Y)
times
[1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
times <- as.Date(paste("31", times, sep="-"), "%d-%m-%Y")
times
[1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
times <- format(as.Date(time, "%b_%Y"), "31-%m-%Y")
# NA
I'm not quite sure how to proceed.