Agricultural monitoring data may be captured for crop seasons, irrigation cycles, or monthly production runs. This helper aggregates tidy monitoring records to the reporting period while concatenating the period labels and summing numeric metrics such as energy consumption, service proxies, and production levels. month). `NULL`, all numeric columns are aggregated. the monitoring periods.

aggregate_monitoring_periods_iif(monitoring_data,
                                             period_col = "monitoring_period",
                                             group_cols = NULL,
                                             summarise_cols = NULL,
                                             output_col = "monitoring_period")

Arguments

monitoring_data

Tibble containing monitoring records.

period_col

Column containing the monitoring period label (e.g. season or

group_cols

Character vector of columns describing facility identifiers.

summarise_cols

Optional character vector of numeric columns to sum. If

output_col

Name of the column storing the concatenated period labels.

Value

A tibble aggregated by `group_cols` with numeric columns summed across

Examples

monitoring <- tibble::tibble(
  facility_id = rep("rice_mill_1", 3),
  season = c("Early", "Mid", "Late"),
  project_total_energy_mwh = c(12.5, 11.8, 11.2),
  processed_grain_tonnes = c(140, 150, 138)
)
aggregate_monitoring_periods_iif(monitoring, period_col = season, group_cols = "facility_id")
#> # A tibble: 1 × 4
#>   facility_id monitoring_period project_total_energy_mwh processed_grain_tonnes
#>   <chr>       <chr>                                <dbl>                  <dbl>
#> 1 rice_mill_1 Early, Mid, Late                      35.5                    428