mlr-org / mlr3gallery

Case studies using mlr3
https://mlr3gallery.mlr-org.com
21 stars 9 forks source link

Render large data tables as HTML #69

Closed mllg closed 3 years ago

mllg commented 4 years ago

There are packages for this, we should use them for larger tables.

mllg commented 3 years ago

@be-marc can you give it a try?

be-marc commented 3 years ago

PR #102 is going to use the following rules for tables:

  1. Include our custom css file in the YAML section which reduces the font size of tables.
output:
  distill::distill_article:
    self_contained: false
    css: ../../custom.css
  1. Limit tables to important columns and rows.
as.data.table(bmr)[, .(learner_id, classif.ce)]

head(as.data.table(bmr))
  1. Convert data.table::data.table() and data.frame() to html tables.
```{r chunk-name, results = 'hide'}
as.data.table(bmr)
as.data.table(bmr) %>%
  kable(format = "html") %>%
  kable_styling(full_width = TRUE)

1. Apply a wider [distill layout](https://rstudio.github.io/distill/figures.html) for wide tables.

````r
```{r chunk-name, layout="l-body-outset"}
as.data.table(bmr)
as.data.table(bmr)

1. Use a vertical scroll box if the table is too long.

````r
```{r chunk-name-2, echo = FALSE}
as.data.table(bmr) %>%
  kable(format = "html") %>%
  kable_styling(full_width = TRUE) %>%
  kableExtra::scroll_box(height = "400px", extra_css = "border: 0px !important;")