Summarize daily flux into hour

Hi @mhab,

May I advise, for the next time, to provide a reproducible example?

However, this time it was relatively easy to create a sample dataset from your example and hopefully the following code provides what you're looking for?

With mutate() I've added an extra column hour to the dataset and two examples of counting is provided.

library(tidyverse)
library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#> 
#>     date, intersect, setdiff, union

df <- tibble::tribble(
        ~Item,          ~datetime, ~Obs, ~micro.form, ~Exp_Flux,
           1L, "31/08/2018 12:48",   1L,        "HP",      6.12,
           2L, "31/08/2018 12:52",   2L,        "PB",      2.89,
           3L, "31/08/2018 12:55",   3L,        "FP",      3.22,
           4L, "31/08/2018 12:59",   4L,        "HP",     10.07,
           5L, "31/08/2018 13:02",   5L,        "PB",      5.87,
           6L, "31/08/2018 13:06",   6L,        "FP",      2.95,
           7L, "31/08/2018 13:09",   7L,        "HP",      4.27,
           8L, "31/08/2018 13:13",   8L,        "PB",      2.27,
           9L, "31/08/2018 13:16",   9L,        "FP",      3.77,
           1L, "31/08/2018 13:20",  10L,        "HP",     10.71,
           1L, "31/08/2018 13:24",  11L,        "PB",      6.15,
           1L, "31/08/2018 13:27",  12L,        "FP",      3.18,
           1L, "31/08/2018 13:31",  13L,        "HP",       1.3,
           1L, "31/08/2018 13:34",  14L,        "PB",      2.61,
           1L, "31/08/2018 13:38",  15L,        "FP",      3.32,
           1L, "31/08/2018 13:41",  16L,        "HP",      4.87,
           1L, "31/08/2018 13:45",  17L,        "PB",      3.19,
           1L, "31/08/2018 13:48",  18L,        "FP",      3.09,
           1L, "31/08/2018 13:52",  19L,        "HP",      2.55,
           2L, "31/08/2018 13:55",  20L,        "PB",      1.68
        )

df <- df %>%
  mutate(datetime = dmy_hm(datetime),
         hour = hour(datetime)
  )
df %>% head()
#> # A tibble: 6 x 6
#>     Item datetime              Obs micro.form Exp_Flux  hour
#>    <int> <dttm>              <int> <chr>         <dbl> <int>
#>  1     1 2018-08-31 12:48:00     1 HP             6.12    12
#>  2     2 2018-08-31 12:52:00     2 PB             2.89    12
#>  3     3 2018-08-31 12:55:00     3 FP             3.22    12
#>  4     4 2018-08-31 12:59:00     4 HP            10.1     12
#>  5     5 2018-08-31 13:02:00     5 PB             5.87    13
#>  6     6 2018-08-31 13:06:00     6 FP             2.95    13

## count # of readings per hour per `micro.form` 
df %>% 
  count(hour, micro.form)
#> # A tibble: 6 x 3
#>    hour micro.form     n
#>   <int> <chr>      <int>
#> 1    12 FP             1
#> 2    12 HP             2
#> 3    12 PB             1
#> 4    13 FP             5
#> 5    13 HP             5
#> 6    13 PB             6

## sum up all `Exp_Flux` per hour per `micro.form`
df %>% 
  count(hour, micro.form, wt = Exp_Flux)
#> # A tibble: 6 x 3
#>    hour micro.form     n
#>   <int> <chr>      <dbl>
#> 1    12 FP          3.22
#> 2    12 HP         16.2 
#> 3    12 PB          2.89
#> 4    13 FP         16.3 
#> 5    13 HP         23.7 
#> 6    13 PB         21.8

Created on 2021-02-10 by the reprex package (v1.0.0)

HTH