read_from_spec: Read a dataset from a data specification file

View source: R/table1c.R

read_from_specR Documentation

Read a dataset from a data specification file

Description

This convenience function can be used to read a dataset and augment it with meta-information from a specification file. The specification file is a YAML file with certain format. Using the function allows a cleaner separation of script logic from data and meta-data, resulting in more generic and re-usable scripts (the data and meta-data can be centralized and segregated from the scripting logic).

Usage

read_from_spec(spec, read.fun = read.csv, file = NULL, ...)

Arguments

spec

Either the name of a YAML file that contains the data specification, or an equivalent object (i.e. as returned by read_yaml).

read.fun

A function that reads in data. It should accept a file name as its first argument and return some sort of data.frame.

file

The name of the file containing the data. if NULL, then the file name will be taken from the dataset item of the data specification.

...

Additional arguments that get passed to read.fun.

Value

A data.frame, as returned by read.fun, that has been augmented with meta-information from the data specification (i.e. labels, factor levels).


certara/table1c documentation built on Oct. 12, 2022, 8:39 a.m.