R/v_fmt_to_width.R

Defines functions v_fmt_to_width

v_fmt_to_width <- function(v_fmt){

  width <- abs(
    as.numeric(
      extr_substr(v_fmt, "(?<=%)-*[[:digit:]]+")
      )
    )

  if(length(width) < 1) width = NA_real_

  nspaces <- nchar(gsub("[^ *]", "", v_fmt))

  full_width <- width + nspaces

  names(full_width) <- NULL

  return(full_width)
}

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.