The programmatic counterpart of read_shell(): builds and validates a shell2tlf_shell from an in-memory list, so shells can be assembled in code or in tests without a file on disk.

new_shell(x, source_file = NA_character_)

Arguments

x

A list with the same structure as the YAML in read_shell().

source_file

Optional path recorded for traceability, shown in the header comment of shell_code().

Value

An object of class shell2tlf_shell.

Examples

shell <- new_shell(list(
  meta = list(id = "t_demo"),
  title = "Table 1",
  population = list(dataset = "adsl"),
  columns = list(var = "TRT01A", total = "Total"),
  rows = list(list(var = "AGE", label = "Age (years)", type = "summary",
                   stats = c("n", "mean_sd")))
))
shell
#> 
#> ── shell2tlf display shell ─────────────────────────────────────────────────────
#>  Table 1
#>  Dataset: adsl | population: all records
#>  Columns: TRT01A + Total
#> 
#> ── Rows ──
#> 
#>  [summary] AGE - Age (years) (n, mean_sd)
#>  Footnotes: 0 | rows per page: 24 (portrait)