add_period: Add period to referendum data

add_periodR Documentation

Add period to referendum data

Description

Augments data with an additional column holding the specified period in which the referendum took place. The new column is named after period and its values are always of type integer.

Usage

add_period(
  data,
  period = c("week", "month", "quarter", "year", "decade", "century")
)

Arguments

data

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

period

Type of period to add. One of "week", "month", "quarter", "year", "decade" or "century".

Details

Note that the period types "year", "decade" and "century" are unique timespans, while "week", "month" and "quarter" are recurring timespans (e.g. every year has a week 1).

Value

A tibble.

See Also

Other referendum data augmentation functions: add_country_code_continual(), add_country_code_long(), add_country_name(), add_country_name_long(), add_former_country_flag(), add_turnout(), add_urls(), add_world_regions()

Examples

rdb::rfrnds(quiet = TRUE) |>
  rdb::add_period() |>
  dplyr::select(id, date, week)

rdb::rfrnds(quiet = TRUE) |>
  rdb::add_period("year") |>
  dplyr::select(id, date, year)

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