Reputation: 51
data = read.csv('Report.csv', stringsAsFactors = FALSE, strip.white=TRUE, as.is = TRUE)
data = data.frame(Date = "2009-04-18", data)
data$Date = as.Date(data$Date, "%Y/%m/%d")
It keeps giving me the charToDate(x) error
(character string is not in a standard unambiguous format).
I have 0 idea what is wrong. My ultimate goal is to create a date column in this data frame.
Upvotes: 0
Views: 7733
Reputation: 14360
Your date variable is formatted as YYYY-MM-DD
, not YYYY/MM/DD
. You are trying to tell R that your separator for your date variable is /
instead of -
(which is what it actually is). That said, this should do the trick:
data$Date = as.Date(data$Date, "%Y-%m-%d")
Upvotes: 1