Home > Software design >  Control output size of modelsummary or DT in bookdown
Control output size of modelsummary or DT in bookdown

Time:09-19

How can I control total size or width of elements like datasummary_skim from modelsummary package or datatable from DT package in bookdown? Those packages are great. But output is too large. I can zoom in and out via browser view, which looks perfectly fine. The commands themselves don't come with these options. Perhaps there is a general html feature to control the size of a code chunk output?

---
title: "Output Size"
author: "Author"
date: "Today"
output: html_document
---

Test 

```{r cars}
library(DT)
datatable(mtcars)

library(modelsummary)
datasummary_skim(mtcars)
```

enter image description here

CodePudding user response:

For a DT table, you can use the width option:

datatable(mtcars, width = "60%")

CodePudding user response:

modelsummary does not actually draw tables itself, but instead support 4 table-drawing packages: kableExtra, gt, huxtable, flextable. Each of these packages offers functions to customize the output, and most include options to customize the size of (at least some) elements.

For example, in the default kableExtra output:

library(modelsummary)
library(kableExtra)
datasummary_skim(mtcars) |>
    kable_styling(font_size = 8, full_width = FALSE)

Please refer to the documentation of these packages for more info.

  • Related