read_facts {rfacts}R Documentation

Read parts of FACTS files.

Description

Read specific fields of a FACTS file.

Usage

read_facts(facts_file, fields)

Arguments

facts_file

Character of length 1, path to FACTS XML file to read.

fields

Data frame defining the kind of XML data to be read. It must have one row per field definition and the following columns:

  1. field: custom name of the field.

  2. type: value of the "type" attribute of the ⁠<parameterSets>⁠ tag.

  3. set: value of the "name" attribute of the ⁠<parameterSet>⁠ tag.

  4. property: value of the "name" attribute of the ⁠<property>⁠ tag.

Details

A FACTS file has a special kind of XML format. Most of the content sits in an overarching ⁠<facts>⁠ tag, then a ⁠<parameterSets>⁠ tag, then a ⁠<parameterSet>⁠ tag, then a ⁠<property>⁠ tag. For example, here is the part of a FACTS file that controls the weeks between interims.

<facts>
  <parameterSets type="NucleusParameterSet">
    <parameterSet name="nucleus">
      <property name="update_freq_save">4</property>

To use the read_facts() function, you must first identify the parts of the FACTS file you want to read using the fields argument. To read the above part of the XML, you would first define the update_freq_save field.

fields <- tibble::tibble(
  field = "my_interval",
  type = "NucleusParameterSet",
  set = "nucleus",
  property = "update_freq_save"
)

and then call read_facts(input = "your_file.facts", fields = fields).

Value

A one-row tibble with the requested fields from the FACTS file.

Examples

facts_file <- get_facts_file_example("contin.facts")
fields <- data.frame(
  field = c("my_subjects", "my_vsr"),
  type = c("NucleusParameterSet", "EfficacyParameterSet"),
  set = c("nucleus", "resp2"),
  property = c("max_subjects", "true_endpoint_response")
)
read_facts(facts_file = facts_file, fields = fields)

[Package rfacts version 0.2.1 Index]