Using `gophr::reshape_msd()` often creates the a perfable long dataset when working with the MSD, but may restrict the user to certain default during the process. Creating a clean period (eg FY22Q1) requires a number of lines of code to get right, so this function provides stopgap when you are working with a long dataset that has a fiscal year and quarter column and desire a period variable.

convert_fy_qtr_to_pd(df, fy_ind = "fiscal_year", qtr_ind = "qtr")

Arguments

df

MSD data frame reshaped long, eg `pivot_longer`

fy_ind

indicator name in df for the fiscal year, default = "fiscal_year"

qtr_ind

indicator name in the df for quarters, default = "qtrs"

Value

united period column combining and cleaning fiscal year and quarter

Examples

if (FALSE) {

df_summary <- df_msd %>%
       filter(indicator == "TX_CURR",
              standardizeddisaggregate == "Total Numerator",
              operatingunit == "Jupiter") %>%
       group_by(mech_code, fiscal_year) %>%
       summarise(across(starts_with("qtr"), sum, na.rm = TRUE),
                 .groups = "drop")

df_summary <- df_summary %>%
       pivot_longer(-c(mech_code, fiscal_year), names_to = "qtrs")

df_summary <- convert_fy_qtr_to_pd(df_summary)
}