R中15分钟时间间隔的水平直方图

时间:2017-06-09 10:03:25

标签: r time count group-by histogram

我想在R中创建一个直方图,如下所示: Histogram count of 15 minutes interval of start and stopdates of weekend and weekdays

因此水平直方图计算工作日和周末日的开始和结束时间为15分钟(而不是图片中的20分钟)。

我一直在使用Split time series data into time intervals (say an hour) and then plot the count的提示,但我并不打算创建我想要的情节。

我的数据集看起来像这样

DF < -Start_datetime End_datetime 2012-02-01 17:35:00 2012-02-01 17:43:44 2012-02-01 17:46:44 2012-03-01 17:50:44 2012-02-01 17:49:50 2012-02-01 18:49:54
2012-02-01 17:42:44 2012-03-01 08:10:44

这就是我尝试过的(只是为了计算开始日期的15分钟间隔):

PTU <- table (cut(DF$Start_datetime, breaks="15 minutes"))
data.frame(PTU)
ggplot(DF, aes(x=PTU))+
        geom_histogram(sta="count", color="blue") +
        labs(x = "Duration", y="Frequency")+
        ggtitle("Duration of charging session")+
        theme(plot.title = element_text(family="Roboto Light", size=16))+
        theme(axis.title = element_text(family="Roboto Light", size=14))

这是我收到的消息:

Warning: Ignoring unknown parameters: binwidth, bins, pad
Error in eval(expr, envir, enclos) : object 'PTU' not found
In addition: There were 14 warnings (use warnings() to see them)

是否有人可以帮助我在工作日/周末将图表调整为单独的图表并正确计算日期的间隔时间?非常感谢!

0 个答案:

没有答案