Your desired output seems to have the count of the rows of data rather than the average of the Flux. I put both values in the code below.
library(lubridate)
#>
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#>
#> date, intersect, setdiff, union
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
DF <- read.csv("~/R/Play/Dummy.csv")
DF <- DF %>% mutate(datetime = dmy_hm(datetime), Date = as.Date(datetime), Hour = hour(datetime))
head(DF)
#> datetime Flux Date Hour
#> 1 2018-08-31 12:55:00 2.88 2018-08-31 12
#> 2 2018-08-31 13:06:00 2.66 2018-08-31 13
#> 3 2018-08-31 13:16:00 2.72 2018-08-31 13
#> 4 2018-08-31 13:27:00 2.85 2018-08-31 13
#> 5 2018-08-31 13:38:00 2.80 2018-08-31 13
#> 6 2018-08-31 13:48:00 2.81 2018-08-31 13
Averages <- DF %>% group_by(Date, Hour) %>%
summarize(Avg = mean(Flux), Count = n())
#> `summarise()` regrouping output by 'Date' (override with `.groups` argument)
Averages
#> # A tibble: 5 x 4
#> # Groups: Date [1]
#> Date Hour Avg Count
#> <date> <int> <dbl> <int>
#> 1 2018-08-31 12 2.88 1
#> 2 2018-08-31 13 2.73 6
#> 3 2018-08-31 14 2.53 5
#> 4 2018-08-31 15 2.75 6
#> 5 2018-08-31 16 2.57 6
Created on 2021-06-02 by the reprex package (v0.3.0)