between_df: between_df

View source: R/between.R

between_dfR Documentation

between_df

Description

Context-sensitive quick filtering or output of logical based on a date range. All assumptions about the data are based on the most recent HUD HMIS Data Standards. The family of *_between functions helps HMIS data analysts easily shape enrollment or project descriptor data based on a single date range, avoiding errors and repeated code.

Usage

between_df(x, status, start = NULL, end = NULL, lgl = FALSE)

Arguments

x

(data.frame) to filter.

status

character, One of "served", "stayed", "entered", "exited", "operating", or "beds_available".

"served"

Enrollments that overlap the date range specified, based on Entry and Exit Dates. Equivalent of served_between()

"stayed"

Enrollments that overlap the date range specified, based on Exit and the Entry Dates for ES, SH, TH projects and Move In Dates for RRH and PSH projects. Requires an EntryAdjust variable in the dataframe. EntryAdjust is based on the ProjectType of the ProjectID associated with the Enrollment and a valid MoveInDate. (Future version will not require EntryAdjust as long as ProjectType and a valid MoveInDate are present in the dataset.) Equivalent of stayed_between()

"entered"

Enrollments where the Entry Date is in the date range specified. Used to find households who entered during date range. Equivalent of entered_between()

"exited"

Enrollments where the Exit Date is in the date range specified. Used to find households who exited during date range. Equivalent of exited_between()

"operating"

Projects where the Operating Start and End dates overlap the date range specified, including those with null Operating End Dates. Equivalent of operating_between()

"beds_available"

Projects with active beds during the date range specified. Equivalent of beds_available_between()

start

Default = ReportStart, character/date of the start of the date range. Characters in format mdY, Ymd, dmY acceptable. Will be automatically retrieved from parent environments if not specified. If start is named other than ReportStart, it must be specified.

end

Default = ReportEnd, character/date of the end of the date range. Characters in format mdY, Ymd, dmY acceptable. Will be automatically retrieved from parent environments if not specified. If end is named other than ReportEnd, it must be specified.

lgl

Default = FALSE, logical, flag to force logical vector output.

Details

Context-sensitive: Automatically detects if nested inside of filter call, if so returns logical instead of data.frame. Enrollment-related functions require Enrollment data elements such as Entry Date, Exit Date, Move In Date, and Project Type (of the Enrollment's Project). Project Descriptor-related functions require Project data elements such as Operating Start/End dates and Bed Inventory Start/End dates.

Value

data.frame/logical after filtering/applying conditional to the appropriate columns

See Also

Other _between: beds_available_between(), entered_between(), exited_between(), operating_between(), served_between(), stayed_between()

Examples

## Not run: 
library(dplyr)
ReportStart <- Sys.Date() - lubridate::weeks(4)
ReportEnd <- Sys.Date()
identical(
served_between(qpr_leavers),
qpr_leavers %>% filter(served_between(., lgl = TRUE))
)

## End(Not run)


COHHIO/HMIS documentation built on Sept. 8, 2024, 7:47 a.m.