R/na_to_minus_99.R

Defines functions na_to_minus_99

na_to_minus_99 <- function(vr_out, fmt){
  if(grepl('-', fmt[1])){
    vr_out <- gsub("(^| )NA( |$)",
                   "\\1-99",
                   vr_out,
                   perl = TRUE)
  }else{
    vr_out <- gsub("(^| )NA( |$)",
                   "-99\\2",
                   vr_out,
                   perl = TRUE)
  }
  return(vr_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.