Skip to contents

tame_dp is the primary function of the tameDP package, reading in the Data Pack and munging in into a tidy data frame to make it more usable to interact with the data than the way it is stored in the Target Setting Tool. **Given the changes to the Target Setting Tool each year, the function only works for the current COP year: COP24.**

Usage

tame_dp(filepath, type = "ALL", map_names = FALSE, psnu_lvl = FALSE)

Arguments

filepath

file path to the Target Setting Tool importing, must be .xlsx

type

dataset to extract "PSNUxIM", "SUBNAT", or "ALL" [default] or a specific tab

map_names

import names from DATIM (OU, mechanism, partner) associated with mech_code

psnu_lvl

aggregate to the PSNU level instead of IM

Details

The main function of `tameDP` is to bring import a COP Target Setting Tool into R and make it tidy. The function aggregates the COP targets up to the mechanism level, imports the mechanism information from DATIM, and breaks out the data elements to make the dataset more usable.

- Imports Target Setting Tool as tidy data frame - Breaks up data elements stored in the indicatorCode column into distinct columns - Cleans up the HTS variables, separating modalities out of the indicator name - Creates a statushiv column - Cleans and separates PSNU and PSNU UID into distinct columns - Adds in mechanism information from DATIM, including operatingunit, funding agency, partner and mechanism name - Removes any rows with no targets - Allows for aggregate to the PSNU level

See also

Other primary: tame_plhiv(), tame_subnat()

Examples

if (FALSE) {
#DP file path
  path <- "../Downloads/DataPack_Jupiter_20500101.xlsx"
#read in Target Setting Tool (straight from sheets, not PSNUxIM tab)
  df_tst <- tame_dp(path)
#read in PLHIV/SUBNAT data
  df_tst <- tame_dp(path, type = "SUBNAT")
#read in PSNUxIM data
  df_tst <- tame_dp(path, type = "PSNUxIM")
#apply mechanism names
  df_tst_named <- tame_dp(path, type = "PSNUxIM", map_names = TRUE)
#aggregate to the PSNU level
  df_tst_psnu <- tame_dp(path, type = "PSNUxIM", psnu_lvl = TRUE)
#reading in multiple files and then applying mechanism names (for PSNUxIM)
  df_all <- map_dfr(.x = list.files("../Downloads/DataPacks", full.names = TRUE),
                    .f = ~ tame_dp(.x, map_names = FALSE))
  df_all <- get_names(df_all)
}