read_file: Read a file

View source: R/read_file.R

read_fileR Documentation

Read a file

Description

Read a file that is either RDS, CSV, JSON, or YAML, with the method determined by the file extension.

Usage

read_file(file, ...)

Arguments

file

Character string of input file; must have file extension .rds, .csv, .json, or .yaml.

...

Passed to whatever function it calls

Details

For CSV files, we use qtl2::fread_csv(), which calls data.table::fread() with a particular set of options; note that columns are forced to be numeric in this case. For RDS files, we use base::readRDS(). For JSON files, we use base::readLines() and jsonlite::fromJSON(). For YAML files, we use yaml::yaml.load_file().

Value

Could be most anything; whatever gets read in by the corresponding R function for the file type. See Details.

Examples

## Not run: w <- read_file("myfile.rds")
x <- read_file("myfile.csv")
y <- read_file("myfile.json")
z <- read_file("myfile.yaml")
## End(Not run)

rqtl/qtl2cl documentation built on Oct. 13, 2024, 1:11 a.m.