每天选择一天中的一小时进行分析

时间:2019-04-11 09:41:08

标签: r date datetime

拥有1年的数据集 每小时记录

为了进行分析,我需要分别提取一年中的每个月,一天中的每个小时,因此1月00h,1月01h,1月02h,1月03h,....,...,3月21h,3月3月22日3月23日

在此先感谢您提供任何有用的帮助!

使用日期时间,过滤器,子集,...选择时段内一天中指定时间的观察值

下面的代码(过滤器,月份(时间)生成致命错误 错误:“ at <-subset(groenenborgerno,timestamp = hour(time)== 01))”中的意外')'

groenenborgerno$timestamp <- as.POSIXct(groenenborgerno$date, format="%Y-%m-%d %H:%M:%S")
library(lubridate)

january01<-filter(atimeframe, 
       (month(time) == 01 & hour(time) == 01) )

1 个答案:

答案 0 :(得分:1)

由于未提供任何数据,因此我将尝试用示例数据回答您的问题:

filter()

,然后只需data %>% filter(hour > 12 & month == 1) # A tibble: 347 x 4 # Groups: month, hour [11] time_index value hour month <dttm> <dbl> <int> <dbl> 1 2017-01-01 13:00:00 0.487 13 1 2 2017-01-01 14:00:00 0.738 14 1 3 2017-01-01 15:00:00 0.576 15 1 4 2017-01-01 16:00:00 -0.305 16 1 5 2017-01-01 17:00:00 1.51 17 1 6 2017-01-01 18:00:00 0.390 18 1 7 2017-01-01 19:00:00 -0.621 19 1 8 2017-01-01 20:00:00 -2.21 20 1 9 2017-01-01 21:00:00 1.12 21 1 10 2017-01-01 22:00:00 -0.0449 22 1 # ... with 337 more rows 您想要的小时/月组合:

CifsConnectionType.WINRM_INTERNAL