Code chunks are now split after result when rendered (recent change) Is there an option to revert this?

A code chunk where results are printed:

x <- "foo"
y <- "bar"
x
y

Used to be rended (in rmarkdown, reprex) as a single code chunk:

x <- "foo"
y <- "bar"
x
#> [1] "foo"
y
#> [1] "bar"

Recently (since a month or two), this is rendered as two code chunks:

x <- "foo"
y <- "bar"
x
#> [1] "foo"
y
#> [1] "bar"

I noticed the change when using devtools::build_readme(), but it is now also the default in reprex, rmarkdown. It is not used by roxygen when rendering the examples of a function (that remains a single code block).

What has triggered this change (a knitr update) and why? Is there a knitr option to revert it? Note that knitr collapse = TRUE (default when creating a vignette) does not affect this.

Thanks!

Found it! It's a knitr regression, reported here Code/output blocks are split · Issue #463 · tidyverse/reprex · GitHub and resolved in knitr 1.48 (Release knitr 1.48 · yihui/knitr · GitHub). So this can be fixed by installing the latest version of knitr (1.48, available on CRAN).

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.