Read specific fields of a FACTS file.

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.

Value

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

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).

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)
#> # A tibble: 1 × 3
#>   facts_file                                                 my_subjects my_vsr
#>   <chr>                                                      <chr>       <list>
#> 1 /Users/runner/work/_temp/Library/rfacts/facts/contin.facts 300         <chr>