R/msd_period.R

Defines functions msd_period

Documented in msd_period

#' Identify MSD Period and Type
#'
#' requires having si_path setup from glamr
#' 
#' @param type Type of MSD (OU_IM, PSNU, PSNU_IM, NAT_SUBNAT)
#' @param period can provide period from ICPIutilities::identifypd(), or it will run if NULL
#'
#' @return FY00Q0t MSD
#' @export
#' 

msd_period <- function(type = "OU_IM", period = NULL){
  file <- glamr::si_path() %>% 
    glamr::return_latest(type)
  
  
  v <- file %>% 
    basename() %>% 
    stringr::str_extract("(?<=_v).{1}")
  
  v <- ifelse(v == "1", "i", "c")
  
  if(is.null(period)){
    period <- file %>% 
      gophr::read_msd() %>% 
      gophr::identifypd()
    
  }
  
  pd <- glue::glue("{period}{v} MSD")
  
  return(pd)
  
}
USAID-OHA-SI/selfdestructin5 documentation built on Feb. 23, 2025, 5:08 a.m.