I’m reading in a CSV into a variable “stuff” and coercing the first column to POSIXct (this column only has timestamps, of the form “2012-12-04 17:49:52”, so this works well).
stuff[,1]<-as.POSIXct(stuff[,1])
Since I have several days’ worth of data, I’m then trying to break things up by date:
control <- subset(stuff,as.Date(stuff[,1]) == '2012-11-27')
control.1 <- subset(stuff,as.Date(stuff[,1]) == '2012-11-28')
I find that this doesn’t split the data up by dates as I would expect.
tail(control) shows me that the last value is at 2012-11-27 15:54:21, while head(control.1) shows that its first value is 2012-11-27 16:04:35.
The equality therefore seems to pivot somewhere around 16:00 for some reason. I tried specifying timezones when coercing to POSIXct, but this didn’t help either. Is there anything I can do to subset by day (and is there a reason this failed)? I’d like to mention that I need to keep the hourly information in there, since I plan on using it to slice up the data subsequently.
Perhaps
cutmight be of use to you, but it is hard to tell for sure without a sample of your data that replicates the problem you’re having.Here’s a minimal example of using
cutto create your daily subsets.