filter_dates: Filter a tibble of data based on the given from and to dates.

View source: R/filters.R

filter_datesR Documentation

Filter a tibble of data based on the given from and to dates.

Description

filter_dates takes a tibble which contains data on a time bound activity and returns the subset of rows where that activity took place within a given period. The tibble must contain two columns of Date objects, which record the start and end dates of an activity. The from and to dates provided are used to find all rows where some part of the period of activity took place within the period of filtering. The filtering process is inclusive: as long as at least one day of activity falls within the filtering period, the row is returned.

Usage

filter_dates(df, start_col, end_col, from_date = NA, to_date = NA)

Arguments

df

A tibble containing data on a time bound activity.

start_col

The name of the column that contains the start date for the activity.

end_col

The name of the column that contains the end date for the activity.

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.

Value

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


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