inst/Examples/splitRepeated.R

splitRepeated <- function(lines,
           separator = "[[:space:]]+",
           numeric = NA) {
    value <- strsplit(lines, separator)
    if(!identical(numeric, FALSE)) {
       warned <- FALSE
       opt <- options(warn = -1); on.exit(options(opt))
       nValue <-  withCallingHandlers(lapply(value, as.numeric),
                warning = function(cond) warned <<- TRUE)
       if(!warned || identical(numeric, TRUE))
           value <- nValue
       options(opt)
       if(warned && identical(numeric, TRUE))
         warning("NAs introduced in coercing to numeric")
   }
    value
}

Try the SoDA package in your browser

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

SoDA documentation built on Oct. 28, 2020, 9:07 a.m.