Unable to suppress paged printing in learnr tutorial exercises.

I am writing a learnr tutorial, and I need to suppress knitr's paged printing. Exercise chunks seem to ignore paged.print = FALSE. Is there another way to suppress paged printing? Reprex below:

---
title: "reprex of paged printing issue"
output: learnr::tutorial
runtime: shiny_prerendered
---

```{r, include = FALSE}
library(learnr)
```

```{r, paged.print = FALSE}
head(mtcars)
```

```{r reprex, exercise = TRUE, paged.print = FALSE, exercise.lines = 1}
head(mtcars)
```

In fact, the exercise chunks also seem to ignore echo = FALSE. What is the best way to disable output from exercises?

Did you already try to change df_print globally ?

---
title: "reprex of paged printing issue"
output: 
  learnr::tutorial:
    df_print: default
runtime: shiny_prerendered
---

It seems to work.

About why it does not work currently, i think it is because paged.print = FALSE is a feature of Rmarkdown only in its render function and here it uses rmarkdown::run. Maybe it should be ported to rmarkdown run (don't know if easy or not).

About disabling output:

  • echo = FALSE will hide the chunk code source, not the output
  • eval = FALSE will disable the evaluation hence the output. with echo = FALSE, you'll get nothing
  • results = "hide" will hide the result
  • include = FALSE is equivalent to echo = FALSE, eval = TRUE and results = 'hide'

Reminder of options are in rmarkdown book : https://bookdown.org/yihui/rmarkdown/r-code.html

Hope it helps

1 Like

Thanks, Christophe! df_print: default works perfectly in my use case.

1 Like

I think I will open something in rmarkdown repo so that the feature of rmarkdown::render that supports paged.print chunk option.

Glad it works for you now !

Just an update as it was not what I thought. Nothing to do with rmarkdown.
It just that learnr does not support paged.print chunk option for exercise chunks as it does not pass it through.
So I guess a feature request is required in learn so that it supports it. But I guess the document format option df_print is maybe enough... :man_shrugging:

1 Like

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