My csv file has datetime data in the format yyyy-mm-dd hh:mm:ss
When I read the file using readr::read_csv()
, the datetime fields are loaded into the data frame as character data. When I try to convert these columns using
as.POSIXct(data_frame["col name"], format="%Y-%m-%d %H:%M:%S")
I get an error saying do not know how to convert to class POSIXct
If all the data in the csv file is for times >= 12:00:00 (on 24 hour clock) read_csv()
will load the data and the datetime fields are dttm objects. If I have records in the csv file with a time less than 12:00:00 read_csv()
will load the data but the datetime fields are loaded as characters. Subsequently I cannot convert them to datetime in the dataframe (RStudio 2022.07.2 build 576).