unnest_var: Unnest multi-value variable

unnest_varR Documentation

Unnest multi-value variable

Description

Unnests a multi-value variable of type list to long format. Multi-value variables can contain more than one value per observation and thus break with the tidy-data convention. This function allows to conveniently expand data to contain a single var value per observation only, thereby increasing the number of observations (i.e. rows).

Usage

unnest_var(data, var)

Arguments

data

RDB referendum data as returned by rfrnds(). A data frame that at minimum contains the column specified in var.

var

data column to unnest. One of the multi-value variables:

  • topics_tier_1

  • topics_tier_2

  • topics_tier_3

  • inst_object_revision_modes

  • inst_topics_only

  • inst_topics_excluded

Tidy selections are supported.

Value

A tibble.

See Also

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

Other variable unnesting functions: var_name_unnested()

Examples

rdb::rfrnds(quiet = TRUE) |>
  rdb::unnest_var(topics_tier_2)

zdaarau/c2d documentation built on Dec. 18, 2024, 1:24 p.m.