Skip to contents

This function takes a data frame and then writes them to a file in the correct format of ROCK attributes.

Usage

attributes_from_df(
  x,
  classInstanceId_col,
  colsToInclude = names(x),
  output = NULL,
  delimiterString = rock::opts$get("delimiterString"),
  attributeContainer = rock::opts$get("attributeContainers")[1],
  silent = rock::opts$get("silent"),
  encoding = rock::opts$get("encoding")
)

attributes_from_spreadsheet(
  x,
  classInstanceId_col,
  colsToInclude = names(x),
  col_renaming = NULL,
  sheet = 1,
  output = NULL,
  delimiterString = rock::opts$get("delimiterString"),
  attributeContainer = rock::opts$get("attributeContainers")[1],
  silent = rock::opts$get("silent"),
  encoding = rock::opts$get("encoding")
)

Arguments

x

For attributes_from_df, the data frame; and for attributes_from_spreadsheet, the path to the spreadsheet (an argument to read_spreadsheet()).

classInstanceId_col

The column name of the column with the class instance identifiers.

colsToInclude

The column names of the columns with the attributes.

output

The filename to write the attributes to.

delimiterString

When exporting to .rock format (as opposed to .yml or .yaml), the delimiter to use to delimit the YAML.

attributeContainer

The name of the root-level YAML node to store the attributes in (the ROCK standard specifies this should be ROCK_attributes).

col_renaming

A named character vector where the names are the current column names and the values are the new names to be used when writing the corresponding attributes.

sheet

The index (or name) of the worksheet containing the attributes.

Value

The produced YAML as a character vector (invisibly if output is NULL).

Details

Note that if the output file has the extension .yml or .yaml, the delimiters passed in delimiterString will be ignored.