Skip to contents

Groups a result of cacs_run() when it is passed to dplyr::group_by(). The method removes the class cacs_run_result and then groups the rows as those of an ordinary tibble, keeping their order. The grouped table keeps the other attributes of .data, and tables computed from it, for example with dplyr::summarise(), are ordinary tibbles.

Usage

# S3 method for class 'cacs_run_result'
group_by(.data, ..., .add = FALSE, .drop = NULL)

Arguments

.data

A cacs_run_result object, as returned by cacs_run().

...

Variables or computations to group by, as in dplyr::group_by().

.add, .drop

Passed to dplyr::group_by(). With .drop = NULL (the default), dplyr's default is used (dplyr::group_by_drop_default()).

Value

A grouped tibble, of class c("grouped_df", "tbl_df", "tbl", "data.frame").

Examples

out <- readRDS(system.file("extdata", "visual_walkthrough_fixture.rds",
                           package = "catchmentACS"))$run_result

# The number of rows for each kind of quantity
out |>
  dplyr::group_by(estimand_family) |>
  dplyr::summarise(rows = dplyr::n())
#> # A tibble: 4 × 2
#>   estimand_family             rows
#>   <chr>                      <int>
#> 1 area_weighted_scalar_proxy     1
#> 2 derived_rate                   5
#> 3 median_proxy                   1
#> 4 spatial_total                 12