This acts as a wrapper function for all the aggregation functions that sit within riskyData
Arguments
- x
A data.table that sits within an R6
HydroImport
object- type
Set the aggregation level to either hourly', 'daily', 'monthly', 'annual', or 'hydroYear'
- method
Available aggregation methods include 'min', 'max', 'mean', 'median', and 'sum'
Value
Aggregated dataset determined from the input type
and method
. Data are placed within a HydroAggs
type container
Examples
# Load bewdley dataset
data(bewdley)
# Calculate mean hourly flows
bewdley$dataAgg(type = "hourly", method = "mean")
#> ℹ Allocating function riskyData::hourlyAgg
#> ✔ Allocating function riskyData::hourlyAgg [74ms]
#>
#> ℹ Computing hourly mean
#> ✔ Computing hourly mean [14s]
#>
#> ℹ Exporting to HydroAggs container
#> ✔ Exporting to HydroAggs container [52ms]
#>
#>
#> ── Class: HydroAggs ────────────────────────────────────────────────────────────
#>
#> ── Private: ──
#>
#> Data Type: Aggregated - hourly mean
#> Station name: Bewdley
#> WISKI ID: 2001
#> Data Type: Flow
#> Modifications: hourly mean
#> Start: 2008-10-01 9
#> End: 2022-10-01 8
#> Time Step: Hourly Unstable
#> Easting: 378235
#> Northing: 276165
#> Longitude: -2.321186
#> Latitude: 52.383072
#>
#>
#> ── Public: ──
#>
#> dateTime hourlyMean
#> <char> <num>
#> 1: 2008-10-01 9 25.500
#> 2: 2008-10-01 10 25.750
#> 3: 2008-10-01 11 25.800
#> 4: 2008-10-01 12 25.725
#> 5: 2008-10-01 13 25.725
#> ---
#> 122708: 2022-10-01 4 11.150
#> 122709: 2022-10-01 5 11.300
#> 122710: 2022-10-01 6 11.675
#> 122711: 2022-10-01 7 11.800
#> 122712: 2022-10-01 8 11.650
#>
#> For more details use the $methods() function, the format should be as
#> `Object_name`$methods()
# Calculate median daily flows
bewdley$dataAgg(type = "daily", method = "median")
#> ℹ Allocating function riskyData::dailyAgg
#> ✔ Allocating function riskyData::dailyAgg [32ms]
#>
#> ℹ Computing daily median
#> ✔ Computing daily median [331ms]
#>
#> ℹ Exporting to HydroAggs container
#> ✔ Exporting to HydroAggs container [19ms]
#>
#>
#> ── Class: HydroAggs ────────────────────────────────────────────────────────────
#>
#> ── Private: ──
#>
#> Data Type: Aggregated - daily median
#> Station name: Bewdley
#> WISKI ID: 2001
#> Data Type: Flow
#> Modifications: daily median
#> Start: 2008-10-01
#> End: 2022-10-01
#> Time Step: Daily Unstable
#> Easting: 378235
#> Northing: 276165
#> Longitude: -2.321186
#> Latitude: 52.383072
#>
#>
#> ── Public: ──
#>
#> dateTime dailyMedian
#> <Date> <num>
#> 1: 2008-10-01 25.80
#> 2: 2008-10-02 69.80
#> 3: 2008-10-03 62.70
#> 4: 2008-10-04 95.50
#> 5: 2008-10-05 122.00
#> ---
#> 5110: 2022-09-27 10.30
#> 5111: 2022-09-28 10.60
#> 5112: 2022-09-29 11.55
#> 5113: 2022-09-30 11.20
#> 5114: 2022-10-01 11.30
#>
#> For more details use the $methods() function, the format should be as
#> `Object_name`$methods()
# Calculate min
bewdley$dataAgg(type = "monthly", method = "min")
#> ℹ Allocating function riskyData::monthlyAgg
#> ✔ Allocating function riskyData::monthlyAgg [17ms]
#>
#> ℹ Computing monthly min
#> ✔ Computing monthly min [582ms]
#>
#> ℹ Exporting to HydroAggs container
#> ✔ Exporting to HydroAggs container [20ms]
#>
#>
#> ── Class: HydroAggs ────────────────────────────────────────────────────────────
#>
#> ── Private: ──
#>
#> Data Type: Aggregated - monthly min
#> Station name: Bewdley
#> WISKI ID: 2001
#> Data Type: Flow
#> Modifications: monthly min
#> Start: 2008 10
#> End: 2022 10
#> Time Step: Monthly Unstable
#> Easting: 378235
#> Northing: 276165
#> Longitude: -2.321186
#> Latitude: 52.383072
#>
#>
#> ── Public: ──
#>
#> dateTime Monthly_Min
#> <char> <num>
#> 1: 2008 10 25.30
#> 2: 2008 11 49.40
#> 3: 2008 12 37.30
#> 4: 2009 1 21.10
#> 5: 2009 2 27.30
#> ---
#> 165: 2022 6 8.60
#> 166: 2022 7 8.40
#> 167: 2022 8 7.91
#> 168: 2022 9 7.99
#> 169: 2022 10 11.10
#>
#> For more details use the $methods() function, the format should be as
#> `Object_name`$methods()
# Calculate annual (calendar year) max
bewdley$dataAgg(type = "annual", method = "max")
#> ℹ Allocating function riskyData::annualAgg
#> ✔ Allocating function riskyData::annualAgg [33ms]
#>
#> ℹ Computing annual max
#> ✔ Computing annual max [84ms]
#>
#> ℹ Exporting to HydroAggs container
#> ✔ Exporting to HydroAggs container [28ms]
#>
#>
#> ── Class: HydroAggs ────────────────────────────────────────────────────────────
#>
#> ── Private: ──
#>
#> Data Type: Aggregated - annual max
#> Station name: Bewdley
#> WISKI ID: 2001
#> Data Type: Flow
#> Modifications: annual max
#> Start: 2008
#> End: 2022
#> Time Step: Annual Unstable
#> Easting: 378235
#> Northing: 276165
#> Longitude: -2.321186
#> Latitude: 52.383072
#>
#>
#> ── Public: ──
#>
#> dateTime annualMax
#> <int> <num>
#> 1: 2008 213
#> 2: 2009 312
#> 3: 2010 248
#> 4: 2011 346
#> 5: 2012 360
#> 6: 2013 376
#> 7: 2014 443
#> 8: 2015 320
#> 9: 2016 323
#> 10: 2017 221
#> 11: 2018 255
#> 12: 2019 375
#> 13: 2020 523
#> 14: 2021 496
#> 15: 2022 470
#>
#> For more details use the $methods() function, the format should be as
#> `Object_name`$methods()
# Calculate hydroYear max
# Hydrological years need to be calculated for this. The `hydroYearDay()` function can be piped into the operation.
bewdley$hydroYearDay()$dataAgg(type = "hydroYear", method = "max")
#> ℹ Calculating hydrological year and day
#> ✔ Calculating hydrological year and day [10s]
#>
#> ℹ Allocating function riskyData::hydroYearAgg
#> ✔ Allocating function riskyData::hydroYearAgg [20ms]
#>
#> ℹ Computing hydroYear max
#> ✔ Computing hydroYear max [68ms]
#>
#> ℹ Exporting to HydroAggs container
#> ✔ Exporting to HydroAggs container [25ms]
#>
#>
#> ── Class: HydroAggs ────────────────────────────────────────────────────────────
#>
#> ── Private: ──
#>
#> Data Type: Aggregated - hydroYear max
#> Station name: Bewdley
#> WISKI ID: 2001
#> Data Type: Flow
#> Modifications: hydroYear max
#> Start:
#> End:
#> Time Step: Hydrological Year Unstable
#> Easting: 378235
#> Northing: 276165
#> Longitude: -2.321186
#> Latitude: 52.383072
#>
#>
#> ── Public: ──
#>
#> hydroYear hydroYearMax
#> <num> <num>
#> 1: 2009 213
#> 2: 2010 312
#> 3: 2011 346
#> 4: 2012 266
#> 5: 2013 376
#> 6: 2014 443
#> 7: 2015 250
#> 8: 2016 323
#> 9: 2017 208
#> 10: 2018 255
#> 11: 2019 291
#> 12: 2020 523
#> 13: 2021 496
#> 14: 2022 470
#>
#> For more details use the $methods() function, the format should be as
#> `Object_name`$methods()
# Calculate total hourly flow
# Flow has to be converted to volume. The `asVol()` function can be piped into the operation.
bewdley$asVol()$dataAgg(type = "hourly", method = "sum")
#> ℹ Calculating volumes
#> ✔ Calculating volumes [29ms]
#>
#> ℹ Allocating function riskyData::hourlyAgg
#> ✔ Allocating function riskyData::hourlyAgg [28ms]
#>
#> ℹ Computing hourly sum
#> ✔ Computing hourly sum [7.8s]
#>
#> ℹ Exporting to HydroAggs container
#> ✔ Exporting to HydroAggs container [13ms]
#>
#>
#> ── Class: HydroAggs ────────────────────────────────────────────────────────────
#>
#> ── Private: ──
#>
#> Data Type: Aggregated - hourly sum
#> Station name: Bewdley
#> WISKI ID: 2001
#> Data Type: Flow
#> Modifications: hourly sum
#> Start: 2008-10-01 9
#> End: 2022-10-01 8
#> Time Step: Hourly Unstable
#> Easting: 378235
#> Northing: 276165
#> Longitude: -2.321186
#> Latitude: 52.383072
#>
#>
#> ── Public: ──
#>
#> dateTime hourlySum
#> <char> <num>
#> 1: 2008-10-01 9 91800
#> 2: 2008-10-01 10 92700
#> 3: 2008-10-01 11 92880
#> 4: 2008-10-01 12 92610
#> 5: 2008-10-01 13 92610
#> ---
#> 122708: 2022-10-01 4 40140
#> 122709: 2022-10-01 5 40680
#> 122710: 2022-10-01 6 42030
#> 122711: 2022-10-01 7 42480
#> 122712: 2022-10-01 8 41940
#>
#> For more details use the $methods() function, the format should be as
#> `Object_name`$methods()