cat.import: reads and returns text and excel files

cat.importR Documentation

reads and returns text and excel files

Usage

cat.import(file, ...)

Arguments

file

full file path

...

Examples

##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (file, ...)
{
    type = stringr::str_extract(file, "[^.]*$")
    if (type == "xlsx") {
        l <- dots_f(list(readxl = "read_excel"), list(...))
        if (is.null(l$sheet))
            l$sheet = 1
        l = c(list(file), l)
        out = data.table::setDT(do.call(readxl::read_excel, l))
    }
    else {
        l <- dots_f(list(data.table = "fread"), list(...))
        l = c(list(file), l)
        out = do.call(data.table::fread, l)
    }
    out[out == ""] <- NA
    return(out)
  }

douve/UEMR documentation built on Aug. 28, 2023, 2:30 p.m.