Home > database >  Linking two code blocks together so that their output appears under the same category in the markdow
Linking two code blocks together so that their output appears under the same category in the markdow

Time:02-12

I've got a couple of charts that show two related data sets. I would like to have them appear in the same 'category' on the markdown, but under two separate 'subtitles' on the table of contents.

My YAML follows this pattern (though I have also used "toc:true" and "toc_float: true" previously):

---
title: "Update"
author: "Me"
date: "`r Sys.Date()`"
output:
  rmdformats::readthedown:
    fig_width: 12
    fig_height: 5
---

The code I use to produce the charts in the markdown follows this format:

# Time-series
##  Nominal

```{r chart1,echo=FALSE, cache=FALSE, warning=FALSE, message=FALSE, fig.height=25,fig.width=10}
Chart1
```
##  Real
```{r chart2,echo=FALSE, cache=FALSE, warning=FALSE, message=FALSE, fig.height=25,fig.width=10}
Chart2
```

The 'category title' (Time-series) and 'subtitle' (Nominal) work as intended, and appear linked in the table of contents when the markdown is produced. The second 'subtitle' (Real) appears unlinked, and while it seems to recognise that 'Real' is intended to be a subtitle in RStudio, when the markdown html is produced it neither recognizes as a subtitle nor does it link it to the 'category title' above. Does anyone how to achieve this?

CodePudding user response:

you are missing a blank line between chunk1 and ## Real

---
title: "Untitled"
author: "domingo"
date: "11 2 2022"
output: 
  html_document:
    toc: TRUE
    toc_float: TRUE
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

# Time-series
##  Nominal

```{r chart1,echo=FALSE, cache=FALSE, warning=FALSE, message=FALSE, fig.height=25,fig.width=10}
plot(mtcars)
```


##  Real
```{r chart2,echo=FALSE, cache=FALSE, warning=FALSE, message=FALSE, fig.height=25,fig.width=10}
plot(mtcars)
```
  • Related