Some functions seem to return/print multiple 'outputs' (e.g., R Console output plus one or multiple data frame). In RStudio preview I can click on these outputs (Example 1 and Example 2). If I render the Quarto file, sometimes rendering the data.frame parts of the output result in nice HTML tables (Example 1) and sometimes the data.frame parts are just rendered "as is" output (Example 2).
Is there a way to have the data.frame part of the output in Example 2 rendered has formatted tables as well (as in Example 1)?
This is just a toy example; I am using the psych
package, where I often have this problem how to print multiple data.frames a function returns as formatted tables.
---
title: "Example"
format:
html:
df-print: paged
---
```{r}
library(tidyverse)
library(knitr)
library(skimr)
df1 <- data.frame(a = c(1, 2, 3))
```
Example 1: Formatted tables in preview and rendered html
```{r}
skim(df1)
```
Example 2: Formatted tables in preview and asis output in rendered html
```{r}
list(df1)
```
Example 1 produces
- in R-Studio preview:
- In Quarto rendered HTML file:
Example 2 produces
- In R-Studio preview
- In Quarto rendered HTML file: