if (!exists("INCLUDE_CHILD_HEADER") || isTRUE(INCLUDE_CHILD_HEADER)) {
  cat("# Panelset knitr Chunks")
}

A common use-case for panelset is to show the code and its output in separate tabs. For example, you might want to first show the code to create a plot in the first tab, with the plot itself in a second tab. On slides where space is constrained, this approach can be useful.

To help facilitate this process, panelset provides a panelset chunk option. When set to TRUE, the code is included in a panel tab named Code and the output is included in a panel tab named Output. Note that you still need to wrap this chunk in a panelset-creating container.

.panelset[
```r`r ''`
list(
  normal = rnorm(10),
  uniform = runif(10),
  cauchy = rcauchy(10)
)
```
]

You can also set the panelset chunk option to a named vector, where the source item is the tab name for the source code and the output item is the tab name for the code output.

```r`r ''`
ggplot(Orange) +
  aes(x = age, y = circumference, colour = Tree) +
  geom_point() +
  geom_line() +
  guides(colour = FALSE) +
  theme_bw()
```

When your code contains multiple expressions and outputs, you may also want to set the results = "hold" chunk option. Currently, knitr uses results = "markup" as the default, in which case each code expression and output pair will generate a pair of tabs.

```r`r ''`
print("Oak is strong and also gives shade.")
print("The lake sparkled in the red hot sun.")
```

Finally, panelset chunks also work in R Markdown documents, but they must be encapsulated in <div class="panelset"> and </div>

<div class="panelset">

```r`r ''`
print("Oak is strong and also gives shade.")
```

</div>

or appear inside a section with the panelset class.

### A Random Sentence {.panelset}

```r`r ''`
print("Oak is strong and also gives shade.")
```


Try the xaringanExtra package in your browser

Any scripts or data that you put into this service are public.

xaringanExtra documentation built on July 16, 2022, 5:06 p.m.