Hi,
My data looks like, it is 24-hourly data (00:00:00 to 23:00:00)
# A tibble: 6 × 5
date BC6 PM2.5_street PM2.5_hurst_road NCORE_PM2P5
<dttm> <dbl> <dbl> <dbl> <dbl>
1 2022-01-01 00:00:00 1.02 NA 13 23
2 2022-01-01 01:00:00 0.120 NA 7 4
3 2022-01-01 02:00:00 0.136 NA 4 2
4 2022-01-01 03:00:00 0.0376 NA 3 NA
5 2022-01-01 04:00:00 0.0372 NA 6 1
6 2022-01-01 05:00:00 0.0326 NA 6 2
# A tibble: 6 × 5
date BC6 PM2.5_street PM2.5_hurst_road NCORE_PM2P5
<dttm> <dbl> <dbl> <dbl> <dbl>
1 2022-01-21 18:00:00 NA 22 5 22
2 2022-01-21 19:00:00 NA 26 12 23
3 2022-01-21 20:00:00 NA 20 18 22
4 2022-01-21 21:00:00 NA 26 20 21
5 2022-01-21 22:00:00 NA 17 8 14
6 2022-01-21 23:00:00 NA 18 13 11
I want to generate only hourly mean. (24 points)
I want to create the data like
date BC6 PM2.5_street PM2.5_hurst_road NCORE_PM2P5
<dttm> <dbl> <dbl> <dbl> <dbl>
1 00:00:00
2 01:00:00
3 02:00:00
4 03:00:00
5 04:00:00
6 05:00:00
7 06:00:00
.
.
24 23:00:00
I tried
aggregate(hourly_mean['BC6'], list(cut(hourly_mean$date, "24 hour")), mean, na.rm=TRUE) -> new_magee1
But, it's giving daily data.
> head(new_magee1)
Group.1 BC6
1 2022-01-01 0.3035197
2 2022-01-02 0.7962944
3 2022-01-03 1.0200813
4 2022-01-04 2.1767271
5 2022-01-05 1.9366458
6 2022-01-06 1.5590944