add_pm: Add Prime Minister to Dated Datasets

Description Usage Arguments Value Examples

View source: R/add.R

Description

It's often useful to know who the Prime Minister was at any point in time when analysing political data. This function takes a dataset that includes a dated variable and adds to it a new column that shows who the Prime Minister was at each moment in time.

Usage

1
add_pm(data = NULL, date = "date", name = "prime_minister")

Arguments

data

A dataset that includes a date variable.

date

The name of your date variable in your data.

name

What to call the new column of Prime Ministers. Defaults to "prime_minister".

Value

A tibble of data.

Examples

1
2
dta <- data.frame(date = seq.Date(as.Date("2000-01-01"), as.Date("2020-01-01"), by = "year"))
add_pm(data = dta, date = "date", name = "prime_minister")

jackobailey/PollBasePro documentation built on Nov. 26, 2021, 7:41 p.m.