
Filter rows in an econanalyzr data frame by a closed date interval
Source:R/econ_filter_dates.R
econ_filter_dates.Rd
Filters 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
Date
orPOSIXt
. IfNULL
, you must provideperiod_type
andperiod_amount
to derive it.- end_date
Optional
Date
orPOSIXt
. IfNULL
, defaults to the latest non-NA date indf
.- period_type
Optional character scalar: one of
"days"
,"weeks"
,"months"
,"quarters"
,"years"
. Used only ifstart_date
isNULL
.- period_amount
Optional positive integer-like scalar (e.g.,
6
for "last 6 months"). Used only ifstart_date
isNULL
.- datetime_tz
Timezone for coercing
POSIXt
inputs toDate
. Default"UTC"
.- quiet
If
FALSE
(default), emit a short message describing the filter.