Print formatted tables in HTML documents for chunks with multiple outputs (e.g., R Console and data frames)

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"
    df-print: paged


df1 <- data.frame(a = c(1, 2, 3)) 

Example 1: Formatted tables in preview and rendered html


Example 2: Formatted tables in preview and asis output in rendered html

Example 1 produces

Example 2 produces

  • In R-Studio preview
  • In Quarto rendered HTML file: