Describes columns of a data table (classes, units, datetime formats, missing value codes).

template_table_attributes(
  path,
  data.path = path,
  data.table = NULL,
  write.file = TRUE,
  x = NULL
)

Arguments

path

(character) Path to the metadata template directory.

data.path

(character) Path to the data directory.

data.table

(character) Table name. If more than one, then supply as a vector of character strings (e.g. data.table = c('nitrogen.csv', 'decomp.csv')).

write.file

(logical; optional) Whether to write the template file.

x

(named list; optional) Alternative input to template_table_attributes(). Use template_arguments() to create x.

Value

attributes_*

Columns:

  • attributeName: Column name

  • attributeDefinition: Column definition

  • class: Column class. Valid options are: "numeric" (Numeric variable), "categorical" (Categorical variable, i.e. nominal), "character" (Free text character strings, e.g. notes), "Date" (Date and time variable)

  • unit: Column unit. Required for numeric classes. Select from EML's standard unit dictionary, accessible with view_unit_dictionary(). Use values in the "id" column. If not found, then define as a custom unit (see custom_units.txt).

  • dateTimeFormatString: Format string. Required for Date classes. Valid format string components are: "Y" (Year), "M" (Month), "D" (Day), "h" (Hour), "m" (Minute), "s" (Second), Common separators of format string components (e.g. "-" "/" "\" ":"") are supported.

  • missingValueCode: Missing value code. Required for columns containing a missing value code).

  • missingValueCodeExplanation: Definition of missing value code.

custom_units

Describes non-standard units used in a data table attribute template. Columns:

  • id: Unit name listed in the unit column of the table attributes template (e.g. feetPerSecond)

  • unitType: Unit type (e.g. velocity)

  • parentSI: SI equivalent (e.g. metersPerSecond)

  • multiplierToSI: Multiplier to SI equivalent (e.g. 0.3048)

  • Abbreviation: Abbreviation (e.g. ft/s)

Details

Character encoding of metadata extracted directly from the tables are converted to UTF-8 via enc2utf8().

Examples

if (FALSE) {
# Set working directory
setwd("/Users/me/Documents/data_packages/pkg_260")

# For 2 tables
template_table_attributes(
  path = './metadata_templates',
  data.path = './data_objects',
  data.table = c('decomp.csv', 'nitrogen.csv'))
}