fetch_mps_party_memberships: Fetch party memberships for all MPs

View source: R/mps.R

fetch_mps_party_membershipsR Documentation

Fetch party memberships for all MPs

Description

fetch_mps_party_memberships fetches data from the Members Names platform showing party memberships for each MP. The memberships are processed and merged so that there is only one row for each period of continuous membership within the same party. A membership with an NA end date is still open.

Usage

fetch_mps_party_memberships(
  from_date = NA,
  to_date = NA,
  on_date = NA,
  while_mp = TRUE,
  collapse = FALSE
)

Arguments

from_date

A string or Date representing a date. If a string is used it should specify the date in ISO 8601 date format e.g. '2000-12-31'. The default value is NA, which means no records are excluded on the basis of the from_date.

to_date

A string or Date representing a date. If a string is used it should specify the date in ISO 8601 date format e.g. 2000-12-31'. The default value is NA, which means no records are excluded on the basis of the to_date.

on_date

A string or Date representing a date. If a string is used it should specify the date in ISO 8601 date format e.g. 2000-12-31'. The default value is NA, which means no records are excluded on the basis of the on_date.

while_mp

A boolean indicating whether to filter the party membership to include only those memberships that were held while each individual was serving as an MP. The default value is TRUE.

collapse

A boolean which determines whether to collapse consecutive memberships within the same party into a single period of continuous party membership. Setting this to TRUE means that party membership ids are not returned in the dataframe. The default value is FALSE.

Details

The from_date and to_date arguments can be used to filter the memberships returned. The on_date argument is a convenience that sets the from_date and to_date to the same given date. The on_date has priority: if the on_date is set, the from_date and to_date are ignored.

The while_mp argument can be used to filter the memberships to include only those that occurred during the period when each individual was an MP.

The filtering is inclusive: a membership is returned if any part of it falls within the period specified with the from and to dates.

The collapse argument controls whether memberships are combined so that there is only one row for each period of continuous membership within the same party. Combining the memberships in this way means that party membership ids from the data platform are not included in the tibble returned.

Note that a membership with an NA end date is still open.

Value

A tibble of party memberships for each MP, with one row per party membership.


houseofcommonslibrary/clmnis documentation built on Aug. 17, 2024, 9:31 p.m.