The function removes duplicated columns, orders the columns as per the order defined by getDataTypeDefinition, optionally removed undefined columns, orders the rows, and finally deletes any data.table keys from the output tables. The input is modified by reference using data.table.

formatOutput(
  data,
  dataType,
  keep.all = TRUE,
  allow.missing = FALSE,
  primaryColumnOrder = NULL,
  secondaryColumnOrder = NULL,
  secondaryRowOrder = NULL,
  removeStoXKeys = FALSE,
  orderColumns = TRUE,
  orderRows = TRUE,
  colsToSplit = NA
)

Arguments

data

A table or list of tables to return from the StoX function.

dataType

The data type to format against.

keep.all

Logical: If TRUE keep all columns, and if FALSE delete undefined columns.

allow.missing

Logical: If TRUE allow for unrelevant column names defined in secondaryColumnOrder.

primaryColumnOrder

Character: A vector of names of columns that should be placed first regardless of the definition of columns specified in the dataTypeDefinition.

secondaryColumnOrder, secondaryRowOrder

A vector of column names specifying order of column not defined by getDataTypeDefinition used to prioritize when ordering columns and rows, respectively.

removeStoXKeys

Logical: If TRUE remove the key columns, which are those ending with "Key".

orderColumns

Logical: If TRUE (the default) order the columns by the first the primaryColumnOrder, then the variables defined for the StoX datatype (as returned by getDataTypeDefinition), then by the secondaryColumnOrder

orderRows

Logical: If TRUE (the default) order the rows first by the values in the variables defined for the StoX datatype (as returned by getDataTypeDefinition), then by the values of the variables specified by secondaryRowOrder. The orderRows can be given as a vector or list of logicals, named by the different tables of the Data, if one wishes to order one but not the other, e.g is the Resolution table is passed unchanged from the input to the output (used e.g. in MeanDensity).

colsToSplit

Character: Either a vector of names of the columns to apply splitting on using setorderv_numeric, or NA (the default) to spply splitting on the columns defined by the elements "surveyDefinition", "horizontalResolution", "verticalResolution" and "obserationVariable" as returned from getDataTypeDefinition of the dataType.