`htmltools tagList`

function.',scap='Two `plotly`

graphics combined into one'}
htmltools::tagList(p) # lapply(p, plotly::as.widget)
```
You can also create figure captions outside of R code by using the `smg, fcap`

HTML tags defined in `markupSpecs`

. The long caption not appearing in the table of contents will be in a separate line without ###.
# Stratified Descriptive Statistics
Produce stratified quantiles, means/SD, and proportions by treatment group. Plot the results before rendering as an advanced html table:
- categorical variables: a single dot chart
- continuous variables: a series of extended box plots
```{r summaryM,cap=paste('Proportions and', mu$chisq(), 'tests for categorical variables')}
s <- summaryM(bili + albumin + stage + protime + sex + age + spiders +
alk.phos + sgot + chol ~ drug, data=pbc,
overall=FALSE, test=TRUE)
plot(s, which='categorical')
```
To construct the caption outside of the code chunk use e.g. ### r cap('Proportions and', mu$chisq(), 'tests for categorical variables') where a backtick is placed before r and after the last ).
```{r summaryM2,results='asis',cap='Extended box plots for the first 4 continuous variables'}
plot(s, which='continuous', vars=1 : 4)
```
```{r summaryM3,cap='Extended box plots for the remaining continuous variables'}
plot(s, which='continuous', vars=5 : 7)
```
```{r summaryM4}
html(s, caption='Baseline characteristics by randomized treatment',
exclude1=TRUE, npct='both', digits=3, middle.bold=TRUE,
prmsd=TRUE, brmsd=TRUE, msdsize=mu$smaller2)
```
Now show almost the full raw data for one continuous variable stratified by treatment. This display spike histograms using at most 100 bins, and also shows the mean and quantiles similar to what is in an extended box plot: 0.05, 0.25, 0.5, 0.75, 0.95. Measures of spread are also shown if the user clicks on their legend entries: Gini's mean difference (mean absolute difference between any two values) and the SD. These can be seen as horizontal lines up against the minimum x-value.
```{r histbox,cap="Spike histograms, means, quantiles, Gini's mean difference, and SD stratified by treatment",scap="Stratified spike histograms and quantiles"}
with(pbc, histboxp(x=sgot, group=drug, sd=TRUE))
```
The following is a better way to display proportions, for categorical variables. If computing marginal statistics by running the dataset through the `Hmisc` `addMarginal` function, the `plot` method with `options(grType='plotly')` is especially useful.
```{r summaryM5,cap='Proportions (large symbols) and proportions stratified by treatment (small symbols)',scap='Proportions with and without stratification by treatment'}
pbcm <- addMarginal(pbc, drug)
s <- summaryP(stage + sex + spiders ~ drug, data=pbc)
# putHcap('Proportions stratified by treatment')
plot(s, groups='drug')
s <- summaryP(stage + sex + spiders ~ drug, data=pbcm)
plot(s, marginVal='All', marginLabel='All Treatment Groups')
```
# Better Demonstration of Boxplot Replacement
```{r support,cap="Spike histograms, means, quantiles, Gini's mean difference, and SD for MAP stratified by diagnosis",scap="Stratified spike histograms and quantiles for MAP"}
getHdata(support2)
with(support2, histboxp(x=meanbp, group=dzgroup, sd=TRUE, bins=200))
```
# Changing Size of Figure Captions
As explained [here](https://stackoverflow.com/questions/45018397), one can place captions under figures using ordinary `knitr` capabilities, and one can change the size of captions. The following example defines a `CSS` style to make captions small (here `0.6em`), and produces a plot with a caption. Unlike using `putHfig` captions given in `knitr` chunks do not also appear in the table of contents.
```{r simplecap,cap='This is a simple figure caption'}
# Note: in the chunk header cap is an alias for fig.cap defined by knitrSet
plot(runif(10))
```
# Computing Environment^[`mu` is a copy of the part of the `Hmisc` package object `markupSpecs` that is for html. It includes a function `session` that renders the session environment (including package versions) in html.] {#compenv}
`r mu$session()`
# Bibliographic File Managament
## Find and Install `.csl` Reference Style Files
```{r findbib,eval=FALSE}
# Note: mu was defined in an earlier code chunk
# Only need to install .csl file once.
mu$installcsl(rec=TRUE) # get list of recommended styles
mu$installcsl() # web search of styles meeting your criteria
# Install a .csl file to your project directory:
mu$installcsl('american-medical-association')
```
`r markupSpecs$markdown$tof()`
Note: the hidden R command that rendered the table of figures (including short captions) was `markupSpecs$markdown$tof()`.