我刚开始与R合作,我需要一些帮助,
我有一个数据框df
,如下所示:
moscow_dt class_name recognition_mode
1 2016-01-01 00:00:04 more than 1 kg Auto
2 2016-01-01 00:00:15 less than 1 kg Manual
3 2016-01-01 00:00:58 more than 1 kg Manual
4 2016-01-01 00:01:21 more than 1 kg Auto
5 2016-01-01 00:01:31 more than 1 kg Auto
6 2016-01-01 00:02:24 more than 1 kg Auto
我希望制作一个表格,向我显示df$class_name
中按小时达到条件more than 1kg
的多个列,如果没有行,则应显示0
,所以它会像那样somithing:
moscow_dt more than 1 kg
1 2016-01-01 00:01:00 3
2 2016-01-01 00:02:00 2
3 2016-01-01 00:03:00 1
4 2016-01-01 00:04:00 0
5 2016-01-01 00:05:00 0
6 2016-01-01 00:06:00 0
我制作了一个包含" 2016-01-01"的每个日期的序列。到" 2016-01-31"按小时计算
dates_by_hour <- seq(from = as.POSIXct("2016-01-01 00-00-00"),to = as.POSIXct("2016-01-31 22-00-00"),by ="hour")
之后我被困了..请帮帮我