We have the ability to create as many levels of "subsector" nesting as we want but in doing so we want to avoid having to make an explict copy of the headers / LEVEL2_DATA_NAMES. So we provide this method which will instruct the ModelIntercae to generate the addtional levels automatically. It assumes the data in the base header is provided as is and the additional columns needed for nesting will be moved to the end (see detail for the column_name and column_order_lookup params).

add_xml_data_generate_levels(
  dot,
  data,
  header,
  old_tag,
  new_tag,
  num_levels,
  rename_final,
  column_name = old_tag,
  column_order_lookup = header
)

Arguments

dot

The current state of the pipeline started from create_xml

data

The tibble of data to add to the conversion

header

The base header tag to can be looked up in the header file to convert data besides the additional levels of nesting.

old_tag

The XML tag which is being expanded to add more levels

new_tag

The XML tag which will serve as the additional levels

num_levels

The number of additional levels to generate

rename_final

Whether to rename the final old_tag to new_tag in the original header

column_name

The base name of the column in data which will get expanded by appending paste0(column_name, (seq_len(num_levels) - 1))

column_order_lookup

A tag that can be used to look up LEVEL2_DATA_NAMES to reorder the columns of data before XML conversion to ensure they correspond with the ModelInterface header. Note by default the header is used then we append the additional columns generated by column_name + num_levels. If given NULL no column reordering will be done.

Value

A "data structure" to hold the various parts needed to run the model interface CSV to XML conversion.

Author

Pralit Patel