Creates a ready-to-print gt table with the number of referendums, optionally counted by
up to three additional variables.
Arguments
- data
RDB referendum data as returned by
rfrnds()
. A data frame that at minimum contains the columns specified inby
(if any).- by
Up to three additional
data
columns 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.- n_rows
Maximum number of rows to be included in the resulting table. All the rows exceeding that limit are replaced by a single row of ellipses. An integer scalar or
Inf
for an unlimited number of rows.- order
How to order the rows of the resulting table. One of
"ascending"
to sort in ascending order by the number of referendums,"descending"
to sort in descending order by the number of referendums, orNULL
to leave the sorting unchanged.
- incl_row_head
Whether or not to include a row heading with the prettified name of the first
by
variable.- incl_col_head
Whether or not to include column headings (in the table's stub) with the prettified names of the second and third
by
variables.- add_total_row
Whether or not to add a summary row at the very end of the table containing column totals. If
NULL
, a total row is added only if at least one column is provided inby
.- add_total_col
Whether or not to add a summary column at the very end of the table containing row totals. If
NULL
, a total column is added only if multiple columns are provided inby
.- lbl_total_row
Label of the summary row containing column totals. Only relevant if
add_total_row = TRUE
. A character scalar.gt::md()
orgt::html()
can be used to format the label text.- lbl_total_col
Label of the summary column containing row totals. Only relevant if
add_total_col = TRUE
. A character scalar.gt::md()
orgt::html()
can be used to format the label text.
Value
A gt_tbl
object.
Details
The first variable specified in by
will be reflected in additional rows in the resulting table, i.e. expand it vertically. The second and third variables
will be reflected in additional columns, i.e. expand it horizontally.
See also
Other tabulation functions:
tbl_n_rfrnds_per_period()
Examples
rdb::rfrnds(quiet = TRUE) |>
rdb::tbl_n_rfrnds()
# grouped by a single column
rdb::rfrnds(quiet = TRUE) |>
rdb::tbl_n_rfrnds(by = level)
Political level
local
subnational
national
Total
# grouped by two columns
rdb::rfrnds(quiet = TRUE) |>
rdb::tbl_n_rfrnds(by = c(type, level))
local
subnational
national
Total
Type
mandatory referendum
optional referendum
counter proposal
citizens’ initiative
governmental referendum
citizens’ assembly
recall
N/A
Total
# grouped by three columns
rdb::rfrnds(quiet = TRUE) |>
rdb::tbl_n_rfrnds(by = c(country_name, level, type),
n_rows = 10L,
order = "descending")
mandatory referendum
optional referendum
counter proposal
citizens' initiative
governmental referendum
citizens' assembly
recall
N/A
mandatory referendum
optional referendum
counter proposal
citizens' initiative
governmental referendum
citizens' assembly
recall
N/A
mandatory referendum
optional referendum
counter proposal
citizens' initiative
governmental referendum
citizens' assembly
recall
N/A
Country
Switzerland
United States
Italy
New Zealand
Liechtenstein
Northern Mariana Islands
Micronesia
Germany
Ecuador
Australia
…
Total
# count ballot dates instead of referendums
rdb::rfrnds(quiet = TRUE) |>
rdb::as_ballot_dates() |>
rdb::tbl_n_rfrnds(by = c(country_name, level),
n_rows = 10L,
order = "descending")
local
subnational
national
Total
Country
Switzerland
United States
Liechtenstein
Germany
Italy
New Zealand
Australia
France
Canada
Ireland
…
Total