I have a csv file with the content like below:
VA1,VA2,2014-05-24,,2014-05-22 15:50:16
VA2,VA1,2014-05-24,2014-05-26,2014-05-22 15:50:16
How can I read it?
Standard read.csv
can not recognize dates YYYY-MM-DD. I've tried to use read.zoo
, but I am not sure how to:
- indicate that two different formats of date & time are used: YYYY-MM-DD and YYYY-MM-DD HH:MM:SS;
- indicate that empty values are possible.
Here is what I've tried:
library(zoo)
colClasses <- c("factor", "factor", "Date", "Date", "Date")
fmt <- "%Y-%m-%d"
z <- read.zoo("file.csv", header = FALSE, sep = ",", quote = "", format = fmt, tz = "", colClasses = colClasses)