Reputation: 251
I am trying to plot time-series data showing the count of observations over a 24 hr period. I have turned my POSIXct variable into a table that looks like this:
ABTable1 <- table(cut(AB_Final1$datetime, breaks="30 mins"))
2016-12-17 00:36:00 2016-12-17 01:06:00 2016-12-17 01:36:00 2016-12-17 02:06:00
2 3 1 1
I want to know how to plot this on a plot running from 00:00 to 23:59. At the moment if I try plot it it runs from 00:36. Is there a way I can make a table that includes all 30 min intervals for this time while retaining my counts? I have to do this multiple times for many plots. Thanks!
Upvotes: 1
Views: 275
Reputation: 24139
You will need to define your break points like this:
breakpoints<-seq(from= as.POSIXct("2016-12-17"), to= as.POSIXct("2016-12-18"), by="30 min")
Then you can substitute these breaks into your cut function:
ABTable1 <- table(cut(AB_Final1$datetime, breaks=breakpoints))
Upvotes: 1