`reshape_msd` transforms the structure into a tidy format. The default reshape, makes the whole dataset long by period, but other options include wide to match the original MSD, semi-wide for a separate column for targets, cumulative, and results, and then a quarterly one which keeps the targets (and cumulative) in their own columsn but makes the quarters long. Reshaping tidy is key for much of OHA/SI processes and analysis.

reshape_msd(
  df,
  direction = c("long", "wide", "semi-wide", "quarters"),
  include_type = TRUE,
  qtrs_keep_cumulative = FALSE
)

Arguments

df

MSD dataset in the semi-wide format

direction

direction of reshape, "long" (default), "wide" (original MSD structure), "semi-wide" (one column for targets, cumulative, results) or "quarters" (quarters pivoted, but not targets - useful for quarterly achievement)).

include_type

whether a period_type column (targets, results, cumulative) should be included, default = TRUE

qtrs_keep_cumulative

whether to keep the cumulative column when using quarters for direction, default = FALSE

Examples

if (FALSE) { # \dontrun{
 #read in data
  df_genie <- match_msd("~/Downloads/PEPFAR-Data-Genie-PSNUByIMs-2018-08-15.zip")
 #reshape long
  df_genie_long <- reshape_msd(df_genie)
 #reshape wide (to look like old format)
  df_genie_long <- reshape_msd(df_genie, direction = "wide")
 #reshape semi-wide (one column for targets, cumulative, results)
  df_genie_wide <- reshape_msd(df_genie, direction = "semi-wide")
 #reshape quarters (quarters pivoted, but not targets - useful for quarterly achievement)
  df_genie_wide <- reshape_msd(df_genie, direction = "semi-wide")
  } # }