Hi there,
I am trying to covert a Date/Time column to just the Date, however, I'm getting an error that I don't know how to fix. When I run the code:
wq.dt$Date <- as.Date(wq.dt$DateTimeStamp)
I get the following error message:
Error in charToDate(x) :
character string is not in a standard unambiguous format
I tried the following:
wq.dt$Date <- as.Date(wq.dt$DateTimeStamp, format = "%MM%DD%YYYY")
But that just gave me a bunch of NA's. It might be because the timestamp is in military time, but I'm not sure how to fix that. Can anyone help? A subset of my data is below.
structure(list(DateTimeStamp = c("06/15/2012 16:00", "06/15/2012 16:15",
"06/15/2012 16:30", "06/15/2012 16:45", "06/15/2012 17:00", "06/15/2012 17:15"
), Temp = c(19.2, 19.2, 18.9, 19.1, 19.2, 19.3), SpCond = c(0.18,
0.18, 0.18, 0.18, 0.18, 0.18), Sal = c(0.1, 0.1, 0.1, 0.1, 0.1,
0.1), DO_Pct = c(79.8, 79.6, 77.7, 78.5, 79, 79.3), DO_mgl = c(7.4,
7.4, 7.2, 7.3, 7.3, 7.3), Depth = c(1.5, 1.54, 1.49, 1.48, 1.45,
1.44), pH = c(7, 7.1, 7.2, 7.2, 7.3, 7.3), Turb = c(12L, 11L,
12L, 12L, 11L, 11L), ChlFluor = c(NA, NA, NA, NA, NA, NA), Date = structure(c(NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), class = "Date")), row.names = 16001:16006, class = "data.frame")
Thank you so much!