NEWS.md

CHANGES IN knitr VERSION 1.47

NEW FEATURES

CHANGES IN knitr VERSION 1.46

NEW FEATURES

BUG FIXES

MAJOR CHANGES

MINOR CHANGES

CHANGES IN knitr VERSION 1.45

NEW FEATURES

BUG FIXES

MAJOR CHANGES

CHANGES IN knitr VERSION 1.44

NEW FEATURES

BUG FIXES

MAJOR CHANGES

MINOR CHANGES

CHANGES IN knitr VERSION 1.43

NEW FEATURES

BUG FIXES

MINOR CHANGES

CHANGES IN knitr VERSION 1.42

NEW FEATURES

MAJOR CHANGES

MINOR CHANGES

BUG FIXES

CHANGES IN knitr VERSION 1.41

NEW FEATURES

BUG FIXES

CHANGES IN knitr VERSION 1.40

NEW FEATURES

BUG FIXES

MINOR CHANGES

CHANGES IN knitr VERSION 1.39

MAJOR CHANGES

MINOR CHANGES

CHANGES IN knitr VERSION 1.38

NEW FEATURES

md ```{exec, command='Rscript'} 1 + 1 ```

The above code chunk executes the Rscript command with the chunk body as its input (which basically means executing the R code in a new R session). See the example #124 in the repo https://github.com/yihui/knitr-examples for more info.

There exists several command-based engines in knitr, such as awk, bash, perl, go, and dot, etc. This new exec engine provides a general mechanism to execute any command that users provide. For example, the code chunk

md ```{bash} echo 'Hello world!' ```

is equivalent to the chunk using the exec engine and the bash command:

md ```{exec, command='bash'} echo 'Hello world!' ```

With this new engine, we no longer need to provide or maintain other simple command-based engines. For example, to support TypeScript (https://github.com/yihui/knitr/pull/1833), we only need to specify command = 'ts-node' with the exec engine.

If the command has significant side-effects (e.g., compile source code to an executable and run the executable, or generate plots to be included in the output), it is also possible to create a new engine based on the exec engine. The example #124 in the knitr-examples repo has provided a gcc example.

We'd like to thank @TianyiShi2001 for the inspiration (#1829 #1823 #1833).

MAJOR CHANGES

MINOR CHANGES

BUG FIXES

CHANGES IN knitr VERSION 1.37

NEW FEATURES

`md{asis, echo=format(Sys.Date(), "%w") == 1} Some conditional content only included when report is built on a Monday

{r} 1 + 1

On another day, this content won't be included. ```` `````

Note that the embedded child code chunks (e.g., in the asis chunk above) are not parsed or evaluated by knitr, and only the top-level code chunk is parsed and evaluated.

`md{comment} Arbitrary content to be commented out.

{r} 1 + 1

The above code chunk will not be executed. Inline code like r pi * 5^2 will be ignored, too. ```` `````

Note that if any line of the content to be commented out contains N backticks, you will have to use at least N + 1 backticks in the chunk header and footer of the comment chunk.

`md{verbatim} We can output arbitrary content verbatim.

{r} 1 + 1

The content can contain inline code like r pi * 5^2, too. ```` `````

By default, the verbatim content is placed in a fenced default code block:

`markdowndefault We can output arbitrary content verbatim.

{r} 1 + 1

The content can contain inline code like r pi * 5^2, too. ```` `````

You can change the default language name of the block via the chunk option lang, e.g., lang = 'markdown' will output a code block like this:

`markdownmarkdown We can output arbitrary content verbatim.

{r} 1 + 1

The content can contain inline code like r pi * 5^2, too. ```` `````

To disable the language name on the block, use an empty string lang = ''.

The difference between the verbatim and asis engine is that the former will put the content in a fenced code block, and the latter just output the content as-is.

You can also display a file verbatim by using the chunk option file, e.g.,

```{verbatim, file="test.Rmd"} ```

This engine also works for other types of documents (e.g., Rnw) but it will not allow for nested code chunks within the verbatim code chunk.

```{embed, file="foo.R"} ```

is equivalent to

```{verbatim, file="foo.R", lang="r"} ```

If you provide the chunk option file to the embed engine, it will read the file and show its content verbatim in the output document. Alternatively, you can specify the file path in the chunk body, e.g.,

```{embed} "foo.txt" ```

The quotes are optional but can be helpful for editors (e.g., RStudio IDE) to autocomplete the file paths.

The syntax highlighting language name is from the filename extension by default, and you can override it with the chunk option lang (e.g., file = "foo.sh", lang = "bash") which is then identical to the verbatim engine.

BUG FIXES

MINOR CHANGES

CHANGES IN knitr VERSION 1.36

MAJOR CHANGES

BUG FIXES

CHANGES IN knitr VERSION 1.35

NEW FEATURES

`{r} #| echo = FALSE, fig.width = 10, #| fig.cap = "This is a long caption."

plot(cars) ``` ````

The main differences between this new syntax and traditional syntax (i.e., chunk options in the chunk header) are: 1) the chunk options can be freely wrapped, i.e., you can write them on as many lines as you prefer; 2) you can also use the YAML syntax instead of the comma-separated syntax if you like, e.g.,

```{r} #| echo: false #| fig.width: 10 ```

Chunk options provided inside a code chunk will override options with the same names in the chunk header if chunk options are provided in both places, e.g.,

```{r, echo = TRUE} #| echo = FALSE, fig.width = 10 ```

The effective chunk options for the above chunk are echo = FALSE and fig.width = 10.

MAJOR CHANGES

```{r} 1 + 1 ```

If you see an error "attempt to use zero-length variable name" when knitting an Rmd document, it may be because of this change, and you may have indented the chunk header by accident. If that is the case, you need to remove the extra white spaces before the chunk header.

The same problem applies to blockquotes, i.e., > before ```. If you quote the chunk header, you have to quote the footer as well, e.g.,

````

{r} 1 + 1 ````

The above unbalanced code chunk needs to be corrected to:

````

{r} 1 + 1 ````

Quoting the chunk body is optional but recommended.

BUG FIXES

CHANGES IN knitr VERSION 1.34

NEW FEATURES

MAJOR CHANGES

MINOR CHANGES

BUG FIXES

CHANGES IN knitr VERSION 1.33

NEW FEATURES

BUG FIXES

MAJOR CHANGES

MINOR CHANGES

CHANGES IN knitr VERSION 1.32

NEW FEATURES

BUG FIXES

MINOR CHANGES

CHANGES IN knitr VERSION 1.31

NEW FEATURES

BUG FIXES

MAJOR CHANGES

MINOR CHANGES

CHANGES IN knitr VERSION 1.30

NEW FEATURES

BUG FIXES

MINOR CHANGES

CHANGES IN knitr VERSION 1.29

NEW FEATURES

BUG FIXES

MAJOR CHANGES

MINOR CHANGES

CHANGES IN knitr VERSION 1.28

BUG FIXES

MAJOR CHANGES

CHANGES IN knitr VERSION 1.27

NEW FEATURES

BUG FIXES

MAJOR CHANGES

MINOR CHANGES

CHANGES IN knitr VERSION 1.26

NEW FEATURES

MINOR CHANGES

CHANGES IN knitr VERSION 1.25

NEW FEATURES

MAJOR CHANGES

MINOR CHANGES

BUG FIXES

CHANGES IN knitr VERSION 1.24

MAJOR CHANGES

BUG FIXES

CHANGES IN knitr VERSION 1.23

NEW FEATURES

BUG FIXES

MAJOR CHANGES

CHANGES IN knitr VERSION 1.22

NEW FEATURES

BUG FIXES

MAJOR CHANGES

MINOR CHANGES

CHANGES IN knitr VERSION 1.21

NEW FEATURES

BUG FIXES

MAJOR CHANGES

MINOR CHANGES

CHANGES IN knitr VERSION 1.20

NEW FEATURES

BUG FIXES

CHANGES IN knitr VERSION 1.19

NEW FEATURES

MAJOR CHANGES

BUG FIXES

CHANGES IN knitr VERSION 1.18

NEW FEATURES

MAJOR CHANGES

BUG FIXES

CHANGES IN knitr VERSION 1.17

MAJOR CHANGES

BUG FIXES

CHANGES IN knitr VERSION 1.16

NEW FEATURES

MAJOR CHANGES

BUG FIXES

CHANGES IN knitr VERSION 1.15.1

NEW FEATURES

BUG FIXES

CHANGES IN knitr VERSION 1.15

NEW FEATURES

MAJOR CHANGES

MINOR CHANGES

BUG FIXES

CHANGES IN knitr VERSION 1.14

NEW FEATURES

BUG FIXES

MAJOR CHANGES

MINOR CHANGES

CHANGES IN knitr VERSION 1.13

NEW FEATURES

BUG FIXES

MAJOR CHANGES

CHANGES IN knitr VERSION 1.12.3

BUG FIXES

CHANGES IN knitr VERSION 1.12

NEW FEATURES

BUG FIXES

MAJOR CHANGES

MINOR CHANGES

CHANGES IN knitr VERSION 1.11

NEW FEATURES

MAJOR CHANGES

BUG FIXES

CHANGES IN knitr VERSION 1.10.5

MAJOR CHANGES

CHANGES IN knitr VERSION 1.10

NEW FEATURES

MAJOR CHANGES

BUG FIXES

CHANGES IN knitr VERSION 1.9

NEW FEATURES

MAJOR CHANGES

MINOR CHANGES

BUG FIXES

CHANGES IN knitr VERSION 1.8

NEW FEATURES

BUG FIXES

CHANGES IN knitr VERSION 1.7

NEW FEATURES

BUG FIXES

MAJOR CHANGES

MINOR CHANGES

CHANGES IN knitr VERSION 1.6

NEW FEATURES

BUG FIXES

MAJOR CHANGES

MINOR CHANGES

CHANGES IN knitr VERSION 1.5

NEW FEATURES

BUG FIXES

MAJOR CHANGES

MINOR CHANGES

CHANGES IN knitr VERSION 1.4

NOTE

NEW FEATURES

MAJOR CHANGES

MINOR CHANGES

BUG FIXES

CHANGES IN knitr VERSION 1.3

NEW FEATURES

BUG FIXES

MAJOR CHANGES

MINOR CHANGES

MAINTENANCE

MISC

CHANGES IN knitr VERSION 1.2

NEW FEATURES

BUG FIXES

MAJOR CHANGES

MINOR CHANGES

DOCUMENTATION

CHANGES IN knitr VERSION 1.1

NEW FEATURES

BUG FIXES

MAJOR CHANGES

MINOR CHANGES

CHANGES IN knitr VERSION 1.0

NEW FEATURES

MAJOR CHANGES

MINOR CHANGES

BUG FIXES

Documentation

CHANGES IN knitr VERSION 0.9

NEW FEATURES

MAJOR CHANGES

MINOR CHANGES

BUG FIXES

DOCUMENTATION

CHANGES IN knitr VERSION 0.8

NEW FEATURES

BUG FIXES

MAJOR CHANGES

MINOR CHANGES

DOCUMENTATION

CHANGES IN knitr VERSION 0.7

NEW FEATURES

BUG FIXES

MAJOR CHANGES

MINOR CHANGES

DOCUMENTATION

CHANGES IN knitr VERSION 0.6.3

MAJOR CHANGES

NEW FEATURES

BUG FIXES

MISC

CHANGES IN knitr VERSION 0.6

NEW FEATURES

BUG FIXES

MAJOR CHANGES

MINOR CHANGES

DOCUMENTATION

CHANGES IN knitr VERSION 0.5

NEW FEATURES

MAJOR CHANGES

BUG FIXES

MISC

CHANGES IN knitr VERSION 0.4

NEW FEATURES

BUG FIXES

MINOR CHANGES

DOCUMENTATION

MISC

CHANGES IN knitr VERSION 0.3

NEW FEATURES

MINOR CHANGES

MAJOR CHANGES

BUG FIXES

MISC

CHANGES IN knitr VERSION 0.2

NEW FEATURES

BUG FIXES

CHANGES IN knitr VERSION 0.1

NEW FEATURES

MISC



yihui/knitr documentation built on April 11, 2024, 2:29 a.m.