R/check_min_exists.R

Defines functions check_min_exists

Documented in check_min_exists

#' Minimum intake food groups check
#'
#' Looks for a minimum value and sets zero if missing,
#' @param df Dataframe.
#' @param check Boolean variable to permit optional food group.
#' @param col Minimum percentage intake column name.
#' @return Dataframe.
#' @export
check_min_exists <- function(df, check, col){
  if(isTRUE(check) && !(col %in% colnames(df))){
    df[col] <- 0
  }
  return(df)
}

Try the DIETCOST package in your browser

Any scripts or data that you put into this service are public.

DIETCOST documentation built on June 8, 2025, 1:51 p.m.