USAID-OHA-SI / WeekendSpecial

SA weekly data munging
0 stars 1 forks source link

Add compatibility for working with CDC data #30

Closed achafetz closed 6 years ago

achafetz commented 6 years ago

adjust code to work with CDC workbooks as well

achafetz commented 6 years ago

Need to align indicators. Check if the light green are the same and then rename.

image

achafetz commented 6 years ago

Current headers also need to be aligned. Need to write a function to add columns where they don't exist. (Not including WEEKLY REPORTING).

image

achafetz commented 6 years ago
  1. crosswalk to standardized indicator names

    #standardize indicator names
      df_long <- df_long %>% 
        dplyr::mutate(indicator = dplyr::case_when(
                          indicator == "Direct HTS_POS"                               ~ "HTS_TST_POS",
                          indicator == "Proxy TX_NEW"                                 ~ "TX_NEW",
                          indicator == "IPT Initiation"                               ~ "IPT",
                          indicator %in% c("Early Missed Appointment", "EarlyMissed") ~ "APPT_EARLY_MISSED",
                          indicator == "Proxy HTS_POS"                                ~ "HTS_TST_POS_PROXY",
                          indicator == "Direct HTS_TST_ART"                           ~ "HTS_TST_ART",
                          indicator == "Unconfirmed Loss to Follow Up"                ~ "LTFU_UNCONFIRMED",
                          indicator == "Waiting for ART"                              ~ "ART_WAITING")
                        )
  2. add columns if missing

#add missing columns if they don't already exist (differences between USAID and CDC)
    cols <- c("province", "provincial_lead", "site_lead", "10x10_facility", "weekly_reporting", "indicator")
    for (c in cols) {
      if(!c %in% colnames(df))
      {
        df <- df %>% 
          dplyr::mutate(!!c := as.character(NA))
      }
    }

  #rename 10x10 facility column (CDC)
    df <- dplyr::rename(df, tenxten_facility = `10x10_facility`)
achafetz commented 6 years ago

Mapping from Mavis

image