add_elections: Add Election Dates to Dated Datasets

View source: R/add.R

add_electionsR Documentation

Add Election Dates to Dated Datasets

Description

It's often useful to know when elections occurred relative to the cases in your data. This function takes a dataset that includes a dated variable and adds to it the date of the last election, next election, or both.

Usage

add_elections(
  data = NULL,
  date = "date",
  last_name = "last_elec",
  next_name = "next_elec",
  which = "both"
)

Arguments

data

A dataset that includes a date variable.

date

The name of your date variable in your data.

last_name

What to call the new column of last election dates. Defaults to "last_elec".

next_name

What to call the new column of next election dates. Defaults to "next_elec".

which

Which elections to return: "last", "next", or "both". Defaults to "both".

Value

A tibble of data.

Examples

add_elections(data = pollbasepro, date = "date", which = "both")

jackobailey/britpol documentation built on Aug. 6, 2023, 2:30 a.m.