Description Usage Arguments Details Value
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.
1 2 3 4 5 6 7 8 9 |
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 |
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. |
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:
oid: original meta table entry id
param: the measured parameter stored in the file
id_ ..: identifier column(s) prefixed with id_
.
file_raw: absolute or project/working directory-relative file path to data set
These will be used to generate a folder structure of the form:
param/id_[1]/id_[2]/.../id_[n-1]
and a processing script within that folder of the form:
param_id_[1]..id_[n].R
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:
param: parameter corresponding to OID in meta table currently processed,
raw_file: path to raw file corresponding to OID in meta table currently processed,
save_dir: path to (new) directory where all outputs from OID in meta table will be saved,
base_file_name: object and file names in processing script (made from template), based on OID in meta table currently processed,
current_index: OID that is currently processed,
date_time: Sys.Date(),
excel_file: logical flag, is raw file MS Excel-based?,
text_file: logical flag, is raw file text based?
meta_table_path: path to meta table
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.
Nothing.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.