filter_memberships: Filter a dataframe of memberships to include only the rows...

View source: R/filters.R

filter_membershipsR Documentation

Filter a dataframe of memberships to include only the rows whose period of membership intersects with those in another dataframe of memberships

Description

filter_memberships is a function to find all memberships in one dataframe that intersect with those in another data frame for each person, or other entity. This function lets you find things like all committee memberships for Commons Members during the period they have served as an MP, or all government roles held by Members of the House Lords while they have served in the Lords.

Usage

filter_memberships(
  tm,
  fm,
  tm_id_col,
  tm_start_col,
  tm_end_col,
  fm_start_col,
  fm_end_col,
  join_col
)

Arguments

tm

A tibble containing the target memberships. These are the memberships to be filtered.

fm

A tibble containing the filter memberships. These are the memberships that are used to filter the target memberships.

tm_id_col

The name of the column in the target memberships that contains the target membership id.

tm_start_col

The name of the column in target memberships that contains the start date for the membership.

tm_end_col

The name of the column in target memberships that contains the end date for the membership.

fm_start_col

The name of the column in filter memberships that contains the start date for the membership.

fm_end_col

The name of the column in filter memberships that contains the end date for the membership.

join_col

The name of the column in both the target and filter memberships that contains the id of the entity that is common to both tables. Where the entity is a person this will be the person id.

Value

A tibble with the same structure as the input tm containing the rows that meet the filtering criteria.


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