prep_data: Prepare data assimilation with templated scripts

Description Usage Arguments Details Value

View source: R/prep_data.R

Description

prep_data() cycles through a meta table (created programmatically or manually) and generates a convenient database-like folder structure and processing scripts based on templates for each dataset entry in the meta table.

Usage

1
2
3
4
5
6
7
8
9
prep_data(
  meta_table_path,
  data_processed_path,
  verbose = TRUE,
  overwrite = FALSE,
  oid = NULL,
  template = NULL,
  data_list = NULL
)

Arguments

meta_table_path

character, txt (tab delimited) with some pre-defined headers, including from automated additions from previous runs of this function

data_processed_path

character, path to data_processed folder (i.e. where cleaned data should live)

verbose

logical, display informative messages and user prompts to proceed?

overwrite

should existing scripts be overwritten?

oid

numeric, length one, row in meta table

template

character, path to custom template

data_list

named list, where names correspond to whisker tokens in template, and values refer to columns in meta table (i.e. meta$column[oid])

Details

The meta table must contain one row per dataset that will be assimilated. It must have at least the following columns, which are used to generate database-like folder structures, processing scripts from templates, and to populate these with information from the meta table:

These will be used to generate a folder structure of the form:

and a processing script within that folder of the form:

as well as intermediate files/outputs from the populated template script with similar naming conventions.

The meta table can include as much detail and information as is desired, and entries can be accessed through token-value combinations in data_list in a custom template. The internal template(s) all have access to fixed set of these token-value combinations (see further below), which are structured following mustache syntax through whisker::whisker.render().

Tokens that are always available and included in the package-internal templates include:

To use a custom template with only internal tokens, supply an empty list: data_list = list().

If there are multiple values or columns in the data, that need to be represented in the meta table, split the column names by forward dashes (/). For example, if a wide table needs to be split into long format, but a unique observation is defined through multiple columns, (e.g. site, plot, tree), these values can be listed as site/plot/tree in a aptly named meta table column for later use in a template.

Value

Nothing.


the-Hull/ROAR documentation built on Jan. 19, 2021, 4:14 p.m.