Skip to contents

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.

Usage

filter_out_years(.data, years_to_exclude)

Arguments

.data

A cd_data object, which contains a dataset with DHIS-2 indicators and demographic data organized by year.

years_to_exclude

An integer vector that specifies the years to exclude from the dataset.

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 valid cd_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 the year does not match any value in years_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))
} # }