From 14846bce6688fcea14c6fc465e64d132415c8e87 Mon Sep 17 00:00:00 2001 From: tessam30 Date: Tue, 9 Jul 2024 10:57:56 -0400 Subject: [PATCH] feat: rebuild site and documentation --- NEWS.md | 3 +- _pkgdown.yml | 12 +- docs/.nojekyll | 1 + docs/404.html | 2 +- docs/LICENSE-text.html | 4 +- docs/articles/create-mdb-tables.html | 312 ------------------ docs/articles/creating-summary-tables.html | 43 +-- docs/articles/index.html | 2 +- docs/authors.html | 6 +- .../bootstrap-5.1.0/bootstrap.bundle.min.js | 7 - .../bootstrap.bundle.min.js.map | 1 - docs/deps/bootstrap-5.1.0/bootstrap.min.css | 1 - .../bootstrap-5.1.3/bootstrap.bundle.min.js | 7 - .../bootstrap.bundle.min.js.map | 1 - docs/deps/bootstrap-5.1.3/bootstrap.min.css | 1 - .../bootstrap-5.2.2/bootstrap.bundle.min.js | 7 - .../bootstrap.bundle.min.js.map | 1 - docs/deps/bootstrap-5.2.2/bootstrap.min.css | 6 - docs/index.html | 6 +- docs/news/index.html | 10 +- docs/pkgdown.yml | 2 +- docs/reference/authors_footnote.html | 5 +- docs/reference/bold_column.html | 2 +- docs/reference/bold_rowgroup.html | 3 +- docs/reference/calc_growth.html | 2 +- docs/reference/caveats_footnote.html | 3 +- docs/reference/change_footnote.html | 3 +- docs/reference/collapse_base_tbl.html | 2 +- docs/reference/collapse_vlc_tbl.html | 2 +- docs/reference/create_mdb.html | 8 +- docs/reference/create_pd.html | 46 +-- docs/reference/dedup_footnote.html | 3 +- docs/reference/delta_footnote.html | 3 +- docs/reference/embiggen.html | 2 +- docs/reference/extract_num_colnames.html | 3 +- docs/reference/fetch_indicators.html | 10 +- docs/reference/fetch_metadata.html | 102 ++++++ docs/reference/format_indicator.html | 2 +- docs/reference/index.html | 52 +-- docs/reference/label_aggregation.html | 2 +- docs/reference/legend.html | 3 +- docs/reference/legend_q1.html | 13 +- docs/reference/legend_q2.html | 13 +- docs/reference/legend_q3.html | 13 +- docs/reference/legend_snapshot.html | 13 +- docs/reference/make_achv_shape.html | 2 +- docs/reference/make_chg_shape.html | 2 +- docs/reference/make_mdb_df.html | 8 +- docs/reference/make_mdb_tx_df.html | 2 +- docs/reference/mdb_main_theme.html | 8 +- docs/reference/mdb_tbl.html | 2 +- docs/reference/mdb_treatment_theme.html | 8 +- docs/reference/msd_period.html | 2 +- docs/reference/past_fy.html | 5 +- docs/reference/pipe.html | 2 +- docs/reference/present_fy.html | 5 +- docs/reference/present_qtr.html | 5 +- docs/reference/reshape_mdb_df.html | 8 +- docs/reference/reshape_mdb_tx_df.html | 8 +- docs/reference/set_metadata.html | 99 ++++++ docs/reference/vlc_footnote.html | 3 +- docs/search.json | 2 +- docs/sitemap.xml | 9 +- 63 files changed, 360 insertions(+), 565 deletions(-) create mode 100644 docs/.nojekyll delete mode 100644 docs/articles/create-mdb-tables.html delete mode 100644 docs/deps/bootstrap-5.1.0/bootstrap.bundle.min.js delete mode 100644 docs/deps/bootstrap-5.1.0/bootstrap.bundle.min.js.map delete mode 100644 docs/deps/bootstrap-5.1.0/bootstrap.min.css delete mode 100644 docs/deps/bootstrap-5.1.3/bootstrap.bundle.min.js delete mode 100644 docs/deps/bootstrap-5.1.3/bootstrap.bundle.min.js.map delete mode 100644 docs/deps/bootstrap-5.1.3/bootstrap.min.css delete mode 100644 docs/deps/bootstrap-5.2.2/bootstrap.bundle.min.js delete mode 100644 docs/deps/bootstrap-5.2.2/bootstrap.bundle.min.js.map delete mode 100644 docs/deps/bootstrap-5.2.2/bootstrap.min.css create mode 100644 docs/reference/fetch_metadata.html create mode 100644 docs/reference/set_metadata.html diff --git a/NEWS.md b/NEWS.md index 1c09703..e7fc63c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,7 +2,8 @@ * Update colors to include the new SI colors * Update internals to no longer rely on call to googledrive * Update final table by adding a status column above achievement circle -* Update the legend to new colors. +* Update the legend to new SI colors +* Update the metadata argument to be entered only once and captured as a pkg env object # selfdestructin5 0.3.1 * Resolve error caused by modification of MSD structure diff --git a/_pkgdown.yml b/_pkgdown.yml index 30a7a45..9c95d6e 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -57,18 +57,20 @@ reference: - create_pd - embiggen - fetch_indicators + - fetch_metadata - format_indicator - label_aggregation - - mdb_tbl - - make_achv_shape - - make_chg_shape - - msd_period - - extract_num_colnames - legend - legend_q1 - legend_q2 - legend_q3 - legend_snapshot + - mdb_tbl + - make_achv_shape + - make_chg_shape + - msd_period + - extract_num_colnames + - set_metadata diff --git a/docs/.nojekyll b/docs/.nojekyll new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/docs/.nojekyll @@ -0,0 +1 @@ + diff --git a/docs/404.html b/docs/404.html index b1b3994..4851141 100644 --- a/docs/404.html +++ b/docs/404.html @@ -31,7 +31,7 @@ selfdestructin5 - 0.3.1 + 0.4.0 - - - - - -
- - - - -
-
- - - -
-

GHSD MSD Summary Tables -

-

The MSD Summary Tables are an SI product created on a quarterly basis -using the latest OU_IM or PSNU_IM MER Structured dataset (MSD). Two -tables are produced, one which summarizes the current achievement for a -set of core (main) indicators, and another which summarizes TX_MMD, VLS, -and VLC (treatment).

-

Starting in FY21 Q2, the SI team migrated the production of the -tables from Tableau to R to reduce the manual burden of creating and -copy and pasting the tables into over 50 briefers. The SI team created a -package to automate the data munging required for the tables. The -selfdestructin5 package is the result of these efforts.

-

Below we review the process for creating the main and treatment -tables.

-
-# Load libraries needed for table creation (glitr, glamr and gophr are OHA-SI packages not on CRAN)
-  library(gagglr)
-  library(tidyverse)
-  library(gt)
-  library(selfdestructin5)
-

Load helper functions/paths from other SI packages.

-
-
-# Set up paths 
-    mdb_out <- "../../Sandbox/" #Alter this path to where you'd like saved tables to go
-    merdata <- si_path("path_msd")
-    msd_path <- return_latest(folderpath = merdata, pattern = "OU_IM")
-    load_secrets()
-    
-# Load OU_IM table - using FY23 Q3 data from Panorama
-    ou_im <- read_psd(msd_path)
-
-# Get the metadata from the MSD dataset; This is used to set the period and source.
-    meta <- get_metadata(msd_path)
-

With our data loaded and time objects created, we are ready to munge -the data. Let’s start with the main table.

-
-  # Main Table
-   # Create the long mdb_df of the main summary indicators 
-   # This will remove mechs with known issues by default. If you want to keep all mechs set `resolve_issues == FALSE`
-      summary_df   <- make_mdb_df(ou_im, pd = meta)
-    
-   # Create the reshaped df that is gt() ready
-      summary_tbl  <- reshape_mdb_df(summary_df, pd = meta)
-    
-   # the `agg_type` column flags the operatingunit as either OU, Region-Country or Agency
-      summary_tbl %>% distinct(agg_type, operatingunit) %>% slice(1:15)
-

The mdb_tbl data frame is a wide-shaped data frame that -contains embedded svg icons from the fontawesome package. -We can pass this to the create_mdb function to make a table -for a desired operating unit.

-
-
-# Generate base table for global results
-    create_mdb(summary_tbl, ou = "Global", type = "main", pd = meta)
-
-# Try a specific country now
-    create_mdb(summary_tbl, ou = "Zambia", type = "main", pd = meta)
-    
-# Or a regional program
-    create_mdb(summary_tbl, ou = "Asia Region-Indonesia", type = "main", pd = meta)
-

The steps are similar for creating the treatment table.

-
-
-# Create the treatment data frame needed for derived indicators
-    summary_df_tx    <- make_mdb_tx_df(ou_im, resolve_issues = F)
-    summary_tbl_tx   <- reshape_mdb_tx_df(summary_df_tx, pd = meta)
-    
-    create_mdb(summary_tbl_tx, ou = "Global", type = "treatment", pd = meta)
-
-
-

Batching Tables -

-

The reshape functions for the main and treatment indicators return a -single data frame of all operating units in PEPFAR, including a Global -and region-country level. Using the agg_type column, we can -define a list of operating units over which we can batch create -tables.

-
-# First, define a function to return the distinct levels in each aggregation type
-
-# create batch tables
- distinct_agg_type <- function(df, type = "OU"){
-   df %>% 
-     filter(agg_type == {{type}}) %>% 
-     distinct(operatingunit) %>% 
-     pull()
-  }
-  
-  # Write the different types to character objects
-  ous <- distinct_agg_type(summary_tbl, "OU")
-  glb <- distinct_agg_type(summary_tbl, "Agency")
-  rgl <- distinct_agg_type(summary_tbl, "Region-Country")
-  
-  # Use purr to map across the list and create tables for all entries in each object
-  purrr::map(ous[2:3], ~create_mdb(summary_tbl, ou = .x, type = "main", pd = meta) %>% 
-        gtsave(., path = mdb_out, filename = glue::glue("{.x}_{meta$curr_pd}_mdb_main.png")))
-  
-  
-  # TREATMENT
-  ous_tx <- distinct_agg_type(summary_tbl_tx, "OU")
-  
-  map(ous[10:12], ~create_mdb(summary_tbl_tx, ou = .x, type = "treatment", pd = meta) %>% 
-        gtsave(., path = mdb_out, filename = glue::glue("{.x}_{meta$curr_pd}_mdb_treatment.png")))
-
-
-

Creating bespoke tables -

-

If there is a core indicator on which you’d like to focus across a -list of operating units, it is possible to use the main or treatment -data frames to create a custom table of OUs by indicator. For example, -say we would like to compare Zambia, Malawi, Mozambique, Tanzania, and -Zimbabwes’s HTS_TST_POS performance. We can filter the -mdb_tbl data frame by a given indicator.

-
-
-# Filter existing wide data frame to desired indicator and OUs
-  mdb_tbl_hts_tst <- summary_tbl %>% 
-    filter(indicator == "HTA_TST_POS", agency == "USAID") %>% 
-    filter(operatingunit %in% c("Malawi", "Zambia", "Tanzania", "Mozambique", "Zimbabwe"))
-
-
-# Pass resulting data frame to the mdb_main_theme() with a bit of rearranging to get a desired sort order.
-  mdb_tbl_hts_tst %>% 
-    mutate(operatingunit = fct_reorder(operatingunit, present_targets_achievement, .desc = T)) %>%  
-    arrange(agency, operatingunit) %>% 
-    gt(groupname_col = "agency") %>% 
-    mdb_main_theme(pd = meta) %>% 
-    cols_unhide("operatingunit") %>% 
-    cols_align(
-      align = "left",
-      columns = operatingunit
-    ) %>% 
-    cols_hide(indicator2) %>% 
-    tab_header(
-      title = glue::glue("HTS_TST Comparison Across OUs")
-    )
-

You can also create a comparison table of OU achievement by core -indicators. With a couple reshapes and filters, you can generate summary -table organized in descending order by TX_CURR.

-
-
-  summary_tbl %>% 
-    filter(agency == "USAID", agg_type == "OU") %>% 
-    select(operatingunit, present_targets_achievement, indicator) %>% 
-    pivot_wider(names_from = indicator, 
-                values_from = present_targets_achievement,
-                names_sort = TRUE) %>% 
-    arrange(desc(TX_CURR)) %>% 
-    gt() %>% 
-    sub_missing(columns = -c("operatingunit"), missing_text = "-") %>% 
-    fmt_percent(columns = -c("operatingunit"), decimals = 0) %>% 
-    cols_label(operatingunit = "") %>% 
-    tab_options(
-      source_notes.font.size = 8,
-      table.font.size = 13, 
-      data_row.padding = gt::px(5)
-    ) %>% 
-    tab_header(title = glue::glue("USAID OU PERFORMANCE SUMMARY FOR {meta$curr_pd}"))
-

If you wish the create tables by implementing partner, you could do -something as below.

-
-# Create a custom function to pull IP tables
-# Filter the MSD to the partner of focus before passing the data to the reshape_msd_df()
-  mk_ptr_tbl <- function(df, mech_id)  {
-    
-    ip_mdb <- 
-      df %>% 
-      filter(mech_code == mech_id) %>% 
-      make_mdb_df(pd = meta) %>% 
-      reshape_mdb_df(., pd = meta) 
-    
-    mech_name <-  
-      df %>% 
-      filter(mech_code == mech_id) %>%
-      distinct(mech_name) %>% 
-      pull(mech_name)
-    
-    ip_mdb %>%   
-      create_mdb(ou = "Minoria", type = "main", pd = meta) %>% 
-      tab_header(
-        title = glue::glue("{mech_name} PERFORMANCE SUMMARY")
-      ) %>% 
-      gtsave(path = "Images", filename = glue::glue("{mech_name}_mdb_main.png"))
-  }
-
-
-# Loop over function and create tables for each of the main C&T mechs
-  mech_list <- c(123456, 789101, 654321)
-  map(mech_list, ~mk_ptr_tbl(df_msd, .x, pd = meta))
-
-
-
- - - -
- - - -
-
- - - - - - - diff --git a/docs/articles/creating-summary-tables.html b/docs/articles/creating-summary-tables.html index 1dd4d86..b80f26c 100644 --- a/docs/articles/creating-summary-tables.html +++ b/docs/articles/creating-summary-tables.html @@ -35,7 +35,7 @@ selfdestructin5 - 0.3.1 + 0.4.0 + + + + + +
+
+
+ +
+

Retrieves the metadata set for the package.

+
+ +
+

Usage

+
fetch_metadata()
+
+ +
+

Value

+ + +

A list containing metadata information.

+
+ +
+

Examples

+
if (FALSE) {
+ meta <- get_metadata()
+}
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/format_indicator.html b/docs/reference/format_indicator.html index 03d642a..37017af 100644 --- a/docs/reference/format_indicator.html +++ b/docs/reference/format_indicator.html @@ -14,7 +14,7 @@ selfdestructin5 - 0.3.1 + 0.4.0 + + + + + +
+
+
+ +
+

Sets the metadata for the package, which can be used across various functions.

+
+ +
+

Usage

+
set_metadata(meta)
+
+ +
+

Arguments

+
meta
+

A list containing metadata information.

+ +
+ +
+

Examples

+ +
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/vlc_footnote.html b/docs/reference/vlc_footnote.html index 050aa36..69fd999 100644 --- a/docs/reference/vlc_footnote.html +++ b/docs/reference/vlc_footnote.html @@ -10,7 +10,7 @@ selfdestructin5 - 0.3.1 + 0.4.0