Just a brief (and hopefully simple!) question;
I have a column of dates such as 08/14
and 08/15
. However the column class is character
, and I was wondering if it is possible (and if so how) to convert this into a date class? I've tried lots of different ways and it either does nothing, or returns N/A
values for the whole column. Hopefully there should be a simple line of code to fix this that I haven't come across yet?
Any help much appreciated!!
One option is to create a day by paste
ing and then use as.Date
because date also needs day info
as.Date(paste0(c("08/14", "08/15"), "/01"), format = "%m/%y/%d")
#[1] "2014-08-01" "2015-08-01"
Or make use of as.yearmon
from zoo
library(zoo)
as.Date(as.yearmon(c("08/14", "08/15"), "%m/%y"))
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments