read_file: Read in a file in a standardized way

Description Usage Arguments Value Author(s) Examples

View source: R/package_functions.R

Description

A wrapper function to read in a file containing data. It uses the file extenstion to determine whether to use the base load or readRDS function for RData and rds files, data.table's fread function for csv files, or readxl's read_excel function for xls and xlsx files.

Usage

1
2
3
read_file(file, inFolder = NULL, showProgress = F,
  na.strings = c("NULL", "NA", "na", "N/A", "n/a", "<NA>", "NONE", "-",
  ".", "", " ", "NaN", "nan", "Inf", "-Inf"), envir = .GlobalEnv, ...)

Arguments

file

A character string giving the name of the file to get the full folder path for (i.e. "main.R").

inFolder

An identifer to narrow the search in case there are multiple files with same name but in different folders (i.e. "Codes/Model1").

showProgress

A boolean (T, F) indicator specifying whether to show the read in progress if using data.table's fread.

na.strings

A vector of character strings to convert to NA

envir

The environment to load the data to

...

Other arguments to pass to data.tables fread, the base load or readRDS, or readxl's read_excel.

Value

A data object (data.table or data.frame).

Author(s)

Alex Hubbard (hubbard.alex@gmail.com)

Examples

1
2
read_file("Model1.R")
read_file("Model1.R", inFolder = "Codes")

opendoor-labs/projectmap documentation built on Oct. 8, 2019, 1:58 p.m.