R/wsv.reader.R

Defines functions wsv.reader

Documented in wsv.reader

#' @describeIn preinstalled.readers Read a whitespace separated values file with the \code{.wsv} or \code{.txt} file extensions.
#' @importFrom utils read.table
#' @importFrom utils unzip
wsv.reader <- function(data.file, filename, variable.name)
{
  if (grepl('\\.zip$', filename))
  {
    tmp.dir <- tempdir()
    tmp.path <- file.path(tmp.dir, data.file)
    file.copy(filename, tmp.path)
    unzip(filename, exdir = tmp.dir)
    filename <- file.path(tmp.dir, sub('\\.zip$', '', data.file))
  }

  assign(variable.name,
         read.table(filename,
                  header = config$data_loading_header),
         envir = .TargetEnv)
}

Try the ProjectTemplate package in your browser

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

ProjectTemplate documentation built on Nov. 20, 2023, 1:06 a.m.