Skip to contents

ARD spec and ARD code

The analyses of a study as a workbook – its datasets, analysis sets, analysis data and one cards / cardx call per analyses row – and the short R program it stands for (tfl_ard_code()), or that program run (tfl_build_ard()): one study ARD.

tfl_read_ard_spec() tfl_ard_spec()
Read and check an ARD definition workbook
tfl_ard_spec_template()
An empty ARD spec
tfl_ard_code()
The R code that makes the study's ARD
tfl_build_ard()
Make the study's ARD from its definition
tfl_ard_for()
One output's part of the study ARD
tfl_ard_spec_hash()
A fingerprint of one output's ARD definition

Methods, statistics and functions of one’s own

What a method may name: the keywords, any cards / cardx function and its arguments, an analysis written as R (custom), a function of the study’s own.

tfl_ard_methods()
The methods an analysis row may name
tfl_ard_statistics()
The statistics an ARD analysis may ask for
tfl_ard_functions()
The ARD functions an analysis may call
tfl_ard_args()
The arguments of one ARD function, and how each is filled in
tfl_ard_as_custom()
An analysis as R: the code of a custom analysis
tfl_ard_function_template()
Start an ARD function of one's own from a template
tfl_ard_function_info()
What the ARD functions of one's own in some R files are

The functions the programs call

The code of the functions the generated programs call as they run (the code lists on a data, the ids in front, the formats, the study ARD), which a study keeps in a file of its own: its programs run without tflspec.

tfl_helpers_code()
The functions a study's generated programs call

Data, analysis data and populations

The datasets, populations and analysis_data sheets of the ARD spec say what is read and how the analysis data are made (see tfl_read_ard_spec()); these write the line that reads a dataset and give data to try things on.

tfl_read_data_code()
The code that reads one dataset of a data catalog
tfl_read_adam()
Read ADaM datasets
tfl_example_adam()
Example ADaM-like data for trying tflspec

An oncology sample study

Simulated ADaM datasets of one oncology study, XYZ-ONC-01 (Drug X vs Control), that agree with one another; its SAP and CRF outline are in system.file("sample", "onco", package = "tflspec").

adsl
Oncology sample study XYZ-ONC-01: subject level (ADSL)
adex
Oncology sample study XYZ-ONC-01: exposure (ADEX)
adae
Oncology sample study XYZ-ONC-01: adverse events (ADAE)
adlb
Oncology sample study XYZ-ONC-01: laboratory (ADLB)
advs
Oncology sample study XYZ-ONC-01: vital signs (ADVS)
adrs
Oncology sample study XYZ-ONC-01: tumour response (ADRS)
adtr
Oncology sample study XYZ-ONC-01: tumour sizes (ADTR)
adtte
Oncology sample study XYZ-ONC-01: time to event (ADTTE)

Document import

A study’s define (Define-XML 2.0 / 2.1, or the workbook it is made from) read by rule: its datasets, variables and code lists, and a report’s code lists and labels as codelists rows.

tfl_read_define()
Read a Define-XML (2.0 or 2.1)
tfl_read_define_spec()
Read a define spec workbook (an import profile)
tfl_define_profile()
An import profile for a define spec workbook
tfl_define_codelists()
A define's code lists as a report's codelists rows

Spec files (YAML)

A study’s spec as files: one report a file, its content: a list of items, one function call each; read, layered over the study’s defaults, checked against the schema, written as code, and converted from the workbooks.

tfl_read_study_spec() tfl_read_outputs()
Read a study's YAML spec
tfl_read_output() tfl_write_output()
Read and write a report's YAML file
tfl_resolve_output()
A report over the layers it extends
tfl_write_study_part()
Write one part of a study's YAML spec
tfl_item_code() tfl_item_written() tfl_item_own()
One content item: its code, its written arguments, its own part
tfl_schema()
The spec schema: the arguments a spec item may give, and their types
tfl_args_to_r() tfl_args_from_r()
An item's arguments as R, and R as an item's arguments
tfl_schema_check()
Check one spec item against the schema
tfl_schema_help()
The help of a spec item's argument
tfl_content_code()
The code of a report's content, from its spec file
tfl_content_run()
Make a report's content, from its spec file, without its code
tfl_convert_sheets_to_yaml() tfl_yaml_from_sheets()
Convert a study's definition sheets to the YAML spec
tfl_write_spec_xlsx()
Write the flat view of a study's YAML spec as a workbook
tfl_import_spec_xlsx()
Take an edited flat-view workbook back into the YAML spec
tfl_sheets_from_yaml() tfl_sheets_from_spec()
The YAML spec as sheets

Table spec and table plan

A table as a workbook: its roles and the rtfreporter plan verbs it stands for, as a plan (tfl_table_plan()) or as code (tfl_table_code()); a plan written in code back to a workbook.

tfl_table_spec()
A workbook-shaped definition of how an ARD becomes a table
tfl_table_spec_template()
Scaffold a definition workbook from an ARD
tfl_table_plan()
A table's plan from its definition
tfl_normalize_code()
The line that normalizes a table's ARD
tfl_table_code()
The code of a table's plan, from its definition
tfl_as_table_spec()
Write a plan as a table definition workbook

Template SPEC

A report kind from a few parameters: one definition gives the table plan (tpl_*(), the A use) and the report’s items (tfl_template_expand(), the B use). Layout templates (summary) and display templates on them (demog). A report’s YAML file may be a template SPEC, template: {name, args}: tfl_resolve_output() resolves it, its program is the template’s call, and tfl_template_to_spec() writes it out as its items.

tfl_templates()
The templates
tfl_template_expand()
Expand a template into a report's items
tfl_template_to_spec()
A template report written out as its items
tpl_demog()
Demographics: a table plan from the template demog
tpl_summary()
Continuous variables by a column key: a table plan from the layout summary
tpl_ae_soc_pt()
Adverse events by SOC and PT: a table plan from the template ae_soc_pt
tpl_hierarchical()
A hierarchy's counts: a table plan from the layout hierarchical
tpl_disposition()
Disposition: a table plan from the template disposition
tpl_shift() tpl_lab_shift()
Shift tables: table plans from the templates shift and lab_shift
tpl_listing()
A listing: a listing plan from the layout listing
tpl_km_table()
Kaplan-Meier estimates: a table plan from the template km_table
tpl_vs_change()
A vital sign's change: a table plan from the template vs_change
tpl_orr()
Objective response: a table plan from the template orr
tpl_ae_overview()
Overview of adverse events: a table plan from the template ae_overview
tfl_read_template_sheets()
Read reports' template SPECs from a workbook
tfl_write_template_yaml()
Write a report's template SPEC as its YAML file

Template SPEC, a company’s templates

A company’s templates are an R package of its own: it registers them when it is loaded (tfl_template(), usually a tflspec template with the company’s defaults), exports the function its reports’ programs call (tfl_template_run()) and tests that no parameter is the look (tfl_test_templates()). tfl_use_company_templates() writes one to start from.

tfl_template()
Register a template
tfl_param()
A template parameter
tfl_template_params()
A template's parameters
tfl_template_run()
Run a template: its table plan
tfl_test_templates()
Test templates: no parameter is the look
tfl_use_company_templates()
Write a company's template package to start from

Report spec, titles, footnotes, headers and tokens

The page, the running header and footer, the titles and footnotes, the tokens: the document around a table, a listing or a figure.

tfl_read_report_spec()
Read a report definition: the table and everything around it
tfl_report()
Build a report's RTF document from its definition
tfl_report_code()
The code of a report's document, from its definition
tfl_report_setup_code()
The study's setup code for its report programs
tfl_report_tokens()
A report's tokens
tfl_report_path()
Where a report's RTF file goes

Listings

Two sheets keyed by output_id, the pages and the program.

tfl_listing_spec() tfl_read_listing_spec() tfl_write_listing_spec()
A listing definition: read, write and check it
tfl_listing()
A listing's pages from its definition
tfl_listing_code()
The code that makes a listing from its definition
tfl_as_listing_spec()
A listing written in code, as a listing spec

Figures

A figure as a YAML design – its data steps, statistics and layers – and the ggplot2 script it stands for.

tfl_fig_design() tfl_write_fig_design() tfl_read_fig_design() tfl_fig_design_code() tfl_check_fig_design()
A figure design
tfl_fig_content_from_design()
A figure design as a figure report's content
tfl_fig_forest_analyses()
The analyses of a forest plot: the figure's own ARD
tfl_fig_templates() tfl_fig_template()
Figure templates
tfl_fig_parts()
The pieces of a figure design
tfl_fig_objects()
The objects a figure's data steps read and make
tfl_fig_page_size()
A figure's size on its report's page
tfl_fig_uses_ard()
Whether a figure's design reads an ARD
tfl_fig_add_layer()
Add a layer to the figure designs' catalog
tfl_fig_calls()
Extension functions a figure design knows
tfl_fig_compat()
ggplot2 3.5 / 4.0 differences for figure designs
tfl_fig_data_name()
The name of a figure's data in its program
tfl_r() tfl_unset() tfl_call() tfl_item() tfl_output()
R objects of the YAML spec

Figure style

Every look-and-feel value of a study’s figures, in one place.

tfl_fig_style() tfl_fig_style_template() tfl_read_fig_style()
The figure style standard
tfl_fig_setup_code() tfl_check_fig()
The helper script of a study's figure programs
tfl_time_unit_days()
The days in a week, a month and a year
tfl_fig_palettes()
Colour palette presets

Figure spec (sheets) and quick figures

The older sheet-based figure spec and its quick figures, kept while the design is decided (Discussion #63).

tfl_fig_spec()
Build a spec from data frames
tfl_fig_spec_template()
Write an Excel spec template with drop-down lists built from ADaM data
tfl_read_fig_spec()
Read an Excel plot spec
tfl_example_fig_spec()
Example plot spec
tfl_fig_code()
Generate ggplot2 code from a plot spec
tfl_write_fig_code()
Write generated code to .R files
tfl_fig_schema()
The arguments of every figure type, described
tfl_fig_types()
Styles of the quick API
tfl_fig_catalog()
Catalogue of clinical figure types
tfl_fig_list_template()
Write an Excel plot list template
tfl_fig_list_code()
Generate code for every row of a plot list
tfl_fig_km()
Kaplan-Meier plot code (ggsurvfit)
tfl_fig_waterfall()
Waterfall plot code
tfl_fig_swimmer()
Swimmer plot code
tfl_fig_forest()
Forest plot code
tfl_fig_mean()
Mean over time code
tfl_fig_box()
Box plot code
tfl_fig_bar()
Bar chart code for rates and category percentages
tfl_fig_scatter()
Scatter plot code
tfl_fig_individual()
Individual profile code (spaghetti / spider)
tfl_fig_pk()
PK concentration-time plot code
tfl_fig_ae_dot()
AE dot plot code
tfl_fig_butterfly()
AE butterfly plot code
tfl_fig_edish()
eDISH plot code
tfl_fig_sankey()
Sankey diagram code for treatment sequences
tfl_fig_sunburst()
Sunburst code for treatment sequences

Sankey diagrams and sunbursts

tfl_plot_sankey()
Plot Sankey Diagram with Rectangular Nodes and Bezier Polygon Links
tfl_plot_sankey_batch()
Batch Create Sankey Plots for Subgroup Analysis
tfl_sankey_data() tfl_sunburst_data()
Sankey / sunburst input from treatment-line data
tfl_plot_sunburst()
Plot a Static Sunburst of Treatment Sequences

CDISC ARS export and import

The specs as CDISC’s Analysis Results Standard (JSON, and CDISC’s Excel template to read), run by siera; anyone’s ARS back as specs.

tfl_ars()
The specs as a CDISC ARS reporting event
tfl_write_ars_json()
Write a CDISC ARS reporting event as JSON
tfl_write_ars_xlsx()
Write a CDISC ARS reporting event as CDISC's Excel template
tfl_ars_unmapped()
What the ARS does not say
tfl_ars_ard()
Make the ARD of a CDISC ARS reporting event with siera
tfl_read_ars_json()
Read a CDISC ARS reporting event from JSON
tfl_ars_to_specs()
A CDISC ARS reporting event as tflspec specs

The YAML spec (one file a report)

The study’s definition as YAML – study.yml, spec/data.yml, spec/defaults.yml, spec/patterns/, spec/toc.yml, one spec/outputs/<id>.yml a report – its objects, the layering of a report over its defaults, the one-time conversion of the sheets, and the flat view as a workbook.

tfl_r() tfl_unset() tfl_call() tfl_item() tfl_output()
R objects of the YAML spec
tfl_plot()
A plot of a figure's content: its name and its items
tfl_read_output() tfl_write_output()
Read and write a report's YAML file
tfl_read_study_spec() tfl_read_outputs()
Read a study's YAML spec
tfl_resolve_output()
A report over the layers it extends
tfl_convert_sheets_to_yaml() tfl_yaml_from_sheets()
Convert a study's definition sheets to the YAML spec
tfl_write_spec_xlsx()
Write the flat view of a study's YAML spec as a workbook
tfl_import_spec_xlsx()
Take an edited flat-view workbook back into the YAML spec

Reading and writing workbooks, the TOC

Each spec has its own reader and writer; several specs may share one workbook. A company’s table of contents becomes report specs, and an ARD a JSON / YAML / XPT copy.

tfl_write_ard_spec()
Write an ARD definition to a workbook
tfl_read_table_spec()
Read an ARD table definition from a workbook
tfl_write_report_spec() tfl_write_table_spec()
Write a table or report definition to a workbook
tfl_write_specs()
Write several specs to one workbook
tfl_spec_columns()
What each column of a spec workbook means
tfl_read_toc()
Read a table of contents (TOC) as report specs
tfl_write_ard()
Write the study ARD as JSON, YAML or XPT
tfl_read_ard()
Read an ARD written by tfl_write_ard()

Checks

What went wrong, said before a report is made: an ARD and what a table reads from it, a function of one’s own, the ARS, a figure, a report’s own code.

tfl_check_ard()
Check an ARD before a report uses it
tfl_check_code()
Check a report's own code against the rules
tfl_check_ard_function()
Try an ARD function of one's own
tfl_ard_conditions()
What went wrong while an ARD was made
tfl_check_ars()
Check a CDISC ARS reporting event
tfl_fig_advice() tfl_fig_apply_fix()
Advice on a figure design
tfl_check_fig_spec()
Check a plot spec against ADaM data

Review of the whole definition

Every report’s problems at once, one row each: what cannot be used, what is probably wrong and what to set by hand; with the facts of the data and of each report’s ARD.

tfl_review_spec()
Review a study's definition
tfl_review_rules()
The rules of the review
tfl_review_templates()
The sentences of the review beyond its rules
tfl_data_facts()
What the data hold, for the review
tfl_ard_facts()
What an ARD holds, for the review

AI manual and kit

The manual of the installed version, and the kit to attach to a chat that drafts a study’s specs from its TOC and shells; each file it returns reviewed, what the AI can correct apart from what the person decides.

tflspec_ai_manual()
The AI assistant manual that ships with this package
tfl_ai_unpack()
Write an AI assistant's answer into a study's spec files
tfl_adam_metadata()
The ADaM metadata to give an AI assistant
tfl_ai_review()
Review the spec an AI assistant wrote

AI-assisted drafting

A prompt for an AI chat that drafts tables’ report files (the code spec) from a company’s TOC / SHELL workbook and an ADaM summary, the study’s TOC, or a figure design; the answer read and checked by tflspec’s own checks, and written as files or shown as what it changes; nothing is sent anywhere.

tfl_ai_read_shell()
A TOC / SHELL workbook as text for an AI chat
tfl_ai_adam_summary()
The ADaM datasets as a summary for an AI chat
tfl_ai_batches()
The TOC's tables in batches, one family each
tfl_ai_write_requests()
Write a study's table requests, one file a request
tfl_ai_prepare()
Prepare a study's AI table requests in one call
tfl_ai_collect_answers()
Read the answers of a study's requests, check them, write the report files
tfl_ai_study_init()
Start a study folder for drafted report files
tfl_ai_tasks()
The tasks AI-assisted drafting knows
tfl_ai_context()
The study facts a drafting prompt carries
tfl_ai_schema()
The schema text of a drafting task
tfl_ai_prompt()
A drafting prompt for an AI chat
tfl_ai_parse()
Read a drafting answer
tfl_ai_check()
Check a drafting answer in its context
tfl_ai_repair_prompt()
The prompt that sends an answer's problems back
tfl_ai_diff()
What a drafting answer changes

Helpers

tflspec_code_options
How the generated programs name folders and packages
print(<tfl_code>)
Code object returned by the quick API