R/v_fmt_to_col_types.R

Defines functions v_fmt_to_col_types

#'
#' @importFrom magrittr "%>%"
#' @importFrom stringr str_extract str_c str_replace_all
#' @importFrom readr cols
#' @importFrom stats setNames
#'
v_fmt_to_col_types <- function(v_fmt){
  v_fmt %>%
    str_extract("[a-z]") %>%
    map(~switch(.,
                "f" = "d",
                "s" = "c")) %>%
    setNames(names(v_fmt)) %>%
    do.call(cols, .)
}

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.