R/check_numeric_fmt.R

Defines functions check_numeric_fmt

check_numeric_fmt <- function(fmt, cname, vr_val){
  if(grepl("%.*f", fmt) & !is.numeric(vr_val)){
    warning(
      paste0('Column ', cname,' is not numeric even though the format indicates it should be. It will be treated as character. Please check output for introduced errors.')
    )
    fmt_out <- gsub("\\.[0-9]f", "s", fmt)
  }else{
    fmt_out <- fmt
  }
  return(fmt_out)
}

Try the DSSAT package in your browser

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

DSSAT documentation built on Nov. 9, 2023, 1:08 a.m.