Add simple functionality to create captions for tabular and long tables
Captions may have a short title that will be used in List of Tables
No explicit support for labels; users can write these into the caption text
Captions always show up in st2report() and st2article() outputs with short titles in ToC (if present)
Captions for long tables are always written to file (caption is part of the table body)
Captions for tabular tables may optionally be written to file
Details
Added st_caption() to set caption in stable pipeline
This function mainly runs on an as.caption() function that can be used for testing or dealing with captions outside of this pipeline setup; main anticipated access point, though, is st_caption()
Captions passed to st_caption() (and as.caption()) can include a short title in brackets at the beginning of the caption text; this will be parsed and optionally repeated at the start of the main caption text
stable() and stable_long() now save the caption as an attribute on stable object
Saved captions may also have a short attribute on them
Saved captions also have a write attribute which indicates whether the caption will be written to file when calling stable_save()
Modified pt_wrap() so that it recognizes caption
Captions are always written out (if they exist) when rendering tables via st2report() or st2article()
Modified stable_save() to optionally write captions out when saving tabular tables
Example
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(pmtables)
a <-
stdata() %>%
st_new() %>%
st_caption(
"[Short title]. Main caption text. \\label{tab::example}",
write = TRUE
) %>% stable()
stable_save(a, file = "foo.tex", dir = "~/")
readLines("~/foo.tex")[1]
#> [1] "\\caption[Short title]{Short title. Main caption text. \\label{tab::example}}"
b <-
stdata() %>%
st_new() %>%
st_caption(
"[Final Model: Population simulations for every 4 week dosing in adults].
Covariates from the adult analysis population were resampled with
replacement to a population of N=1,000 and used to simulate
PK for the following regimen: 50 mg IV every 4 weeks.
Subject-level variability, but not interoccasion or residual error,
was included in the simulations. Summary statistics for pre-dose
concentration and average concentration at steady state were calculated
across all 1,000 resampled patients. \\label{tab:pop-sims-adult}"
) %>% stable_long()
c <-
stdata() %>%
st_new() %>%
st_caption(
"Full Model: Final model parameter estimates\\label{tab:param}",
short = "Full Model Estimates", short_repeat = FALSE
) %>% stable_long()
st2report(list(a,b,c), ntex = 2, output_dir = "~/")
Big picture
st2report()
andst2article()
outputs with short titles in ToC (if present)Details
st_caption()
to set caption in stable pipelineas.caption()
function that can be used for testing or dealing with captions outside of this pipeline setup; main anticipated access point, though, isst_caption()
st_caption()
(andas.caption()
) can include a short title in brackets at the beginning of the caption text; this will be parsed and optionally repeated at the start of the main caption textstable()
andstable_long()
now save the caption as an attribute onstable
objectshort
attribute on themwrite
attribute which indicates whether the caption will be written to file when callingstable_save()
pt_wrap()
so that it recognizes captionst2report()
orst2article()
stable_save()
to optionally write captions out when saving tabular tablesExample
Created on 2023-07-14 with reprex v2.0.2 view-st2report.pdf