convert_fy_qtr_to_pd: Convert Fiscal Year and Quarter into Period

convert_fy_qtr_to_pdR Documentation

Convert Fiscal Year and Quarter into Period

Description

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.

Usage

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

See Also

Other period: convert_date_to_qtr(), convert_datim_pd_to_qtr(), convert_qtr_to_date()

Examples



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)


USAID-OHA-SI/glamr documentation built on July 6, 2024, 6:39 a.m.