Suppress table formatted output in learnr tutorial

Hello

I'm writing some learnr tutorials on linear modelling. If I have something like anova(modelname) in a code chunk or in an exercise then in the rendered tutorial this is formatted as an html formatted table using kable or similar. This seems unique to learnr since it doesn't happen in rmarkdown documents.

I'd rather have the raw text output since this is what the user normally sees, and also these formatted tables tend to be rather wide and fall out of the edge of the window.

I can suppress this by using print(anova(modelname)) but this is not great for exercises since it's not something you'd normally do. I can't see anything in the learnr documentation about something like a global option that would suppress this but if anyone can suggest anything that would be very helpful.

Thanks!

I believe the paged_print option discussed here might do the trick for you. See below example.

   ---
   title: "Tutorial"
   output: learnr::tutorial
   runtime: shiny_prerendered
   ---
   
   ` ``{r setup, include=FALSE}
   library(learnr)
   ` ``
   
   ` ``{r mtcars-anova-kable, exercise=TRUE}
   anova(lm(mpg ~ as.factor(gear), data = mtcars))
   ` ``
   
   ` ``{r mtcars-anova-raw, exercise=TRUE, paged.print=FALSE}
   anova(lm(mpg ~ as.factor(gear), data = mtcars))
   ` ``

Note: I added a space in the backticks for the r chunks so they would show up in the rendered response, so make sure to take them out when trying the code.

Thanks Mine

From what I can read you're right, this should work... but for some reason it doesn't. Everything relevant is up-to-date I think. Doesn't make any difference in the tutorial I'm writing and if I just run your minimal example I get the formatted tables for both chunks.

Not sure if there's anything else I might try.

Thanks

Does the example I gave in my reply work for you as is? If so, but using it in your tutorial doesn't work, you might have other settings in your tutorial that override this somehow. But I'm not sure what that would be without seeing. If you can post a minimum reproducible example like mine, happy to give it a try!

Hello

The example you gave gives me formatted tables for both chunks. Have tried it on both a machine running MacOs and on an Ubuntu box with RStudio freshly restarted and no weird settings that I'm aware of. Any ideas?

Re-opening this as I have the same issue and not finding any solution. I would prefer my audience to see tibble console display in my learnr tutos as they would see them in their own analyses. The proposed solution here from @mine doesn't work. Both chunks displays as if paged.print=T was forced somewhere else. In the html file the console outputs have a class pagedtable-wrapper (vs pre for print(...)) but I don't know where to change this behaviour.

You can control how the tables are printed using the df_print argument of learnr::tutorial(), which can be set in the YAML front matter of your tutorial:

---
output:
  learnr::tutorial:
    df_print: default
---

This sets the data frame printing method throughout the tutorial so that data frames are printed in the same way as a student would see the output in their own analyses. You could also set df_print: tibble to always use the printed tibble format.