R/apply_class.R

Defines functions apply_class

Documented in apply_class

#' Apply variable class
#'
#' Ensure that fiscal year, cumulative, and targets are numeric and all other
#' variables are stored as characters.
#'
#' @param df dataframe output to reorder
#' @export

apply_class <- function(df){
  #ensure variables are same class (problem when missing all targets)
  df <- df %>%
    dplyr::mutate(dplyr::across(dplyr::everything(), as.character),
                  dplyr::across(c(fiscal_year, cumulative, targets), as.double))
  return(df)
}
USAID-OHA-SI/tameDP documentation built on March 16, 2024, 6:26 a.m.