Skip to contents

Counts the number of RDB referendums, optionally by additional columns specified via by.

Usage

n_rfrnds(data, by = NULL, complete_fcts = TRUE)

Arguments

data

RDB referendum data as returned by rfrnds(). A data frame that at minimum contains the columns specified in by (if any).

by

Optional data column(s) to group by before counting number of referendums. Tidy selections are supported.

complete_fcts

Whether or not to complete the result with implicitly missing combinations of those columns specified in by which are of type factor.

Value

A tibble.

See also

Other referendum data transformation functions: as_ballot_dates(), n_rfrnds_per_period(), prettify_col_names(), unnest_var()

Examples

rdb::rfrnds(quiet = TRUE) |>
  rdb::n_rfrnds(by = level)
#> # A tibble: 3 × 2
#>   level           n
#>   <ord>       <int>
#> 1 local          43
#> 2 subnational 14711
#> 3 national     3135

# count ballot dates instead of referendums
rdb::rfrnds(quiet = TRUE) |>
  rdb::as_ballot_dates() |>
  rdb::n_rfrnds(by = level)
#> # A tibble: 3 × 2
#>   level           n
#>   <ord>       <int>
#> 1 local          22
#> 2 subnational  4283
#> 3 national     1633