Can we somehow convert dates such as "November 2017", "December 2017"
to date? I tried to import csv data, but received factor columns.
I tried the following code, but was not successful.
as.POSIXct(as.character(dat$Date), format = "%B %Y")
A POSIXct
date needs the day of the month to be complete and valid.
You can add it to the date strings, then use the format "%B %Y %d"
e.g. :
as.POSIXct(paste(as.character(dat$Date),"01"), format = "%B %Y %d")
BTW, when you import a csv you can set stringsAsFactors=FALSE
(as argument of read.csv/read.table
functions) to obtain characters instead of factors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With