0

I don't quite understand placement of chunks in an Rstudio notebook. I need to know how to make the chunks and results in the markdown appear in the same order as the original document and be able to control which are included using the include= chunk option.

  ---
title: "Test markdown"
output:
  html_notebook: default
---

```{r, setup, include=FALSE}
# set default chunk options:w

knitr::opts_chunk$set(echo = FALSE, include = FALSE, fig.width = 8, collapse = TRUE, warning = FALSE)

```

Note 0

```{r}
# Comment
c <- 92461110
m <- 7056556
```

```{r, include=TRUE}
c
```
Note 1
```{r}
paste("Nothing")
```

Note 2

```{r,include=TRUE}
paste("Something")
```

```{r, include=TRUE}
paste("something else")
```

I should get

Test Markdown

Note 0

92461110

Note 1

Note 2

[1] "Something"

[1] "Something else"

Instead I get

Test markdown

Note 0

Note 1

Note 2

[1] "Nothing"

[1] "Something"
Waylan
  • 37,164
  • 12
  • 83
  • 109
Harlan Nelson
  • 1,394
  • 1
  • 10
  • 22

0 Answers0