
Filter rows in an econanalyzr data frame by a closed date interval
Source:R/econ_filter_dates.R
econ_filter_dates.RdFilters an econanalyzr-valid data frame by a closed date interval
[start_date, end_date]. If start_date is not supplied, you can specify a
period (period_type + period_amount) and the function will compute
start_date = end_date - period (with end_date defaulting to the latest
non-NA date in df).
Usage
econ_filter_dates(
df,
start_date = NULL,
end_date = NULL,
period_type = c("days", "weeks", "months", "quarters", "years"),
period_amount = NULL,
datetime_tz = "UTC",
quiet = FALSE
)Arguments
- df
A data frame validated by
check_econanalyzr_df().- start_date
Optional
DateorPOSIXt. IfNULL, you must provideperiod_typeandperiod_amountto derive it.- end_date
Optional
DateorPOSIXt. IfNULL, defaults to the latest non-NA date indf.- period_type
Optional character scalar: one of
"days","weeks","months","quarters","years". Used only ifstart_dateisNULL.- period_amount
Optional positive integer-like scalar (e.g.,
6for "last 6 months"). Used only ifstart_dateisNULL.- datetime_tz
Timezone for coercing
POSIXtinputs toDate. Default"UTC".- quiet
If
FALSE(default), emit a short message describing the filter.