The filter_out_years
function is used to exclude specified years from a DHIS-2
dataset, refining the data for more targeted analysis or reporting. This is
particularly useful when focusing on specific timeframes, such as recent years
only or a custom-defined analysis period. By removing data from unwanted years,
you can create a tailored dataset aligned with analytical goals.
Value
A cd_data
object with rows filtered to exclude those matching
the specified years in years_to_exclude
. The resulting data set is intended
for focused analysis across the remaining years.
Details
Purpose: Use this function when specific years are unnecessary for analysis, such as baseline years or years with incomplete data.
Validation:
Ensures
.data
is a validcd_data
object for DHIS-2 analysis.Confirms
years_to_exclude
is a vector of integers; raises an error if not properly specified.
Functionality: Filters
.data
to retain only the rows where theyear
does not match any value inyears_to_exclude
.
Examples
if (FALSE) { # \dontrun{
# Example: Remove data for 2017 and 2018 from a DHIS-2 dataset
filtered_data <- filter_out_years(dhis_data, years_to_exclude = c(2017, 2018))
} # }