Skip to content

tinytable #1070

@vincentarelbundock

Description

@vincentarelbundock

Thanks for sharing such an interesting and powerful package!

This is a proof of concept to add support for tinytable, a dependency-free package to draw tables. By implementing a reasonably simple tt.rtables() S3 method, we get:

  1. Powerful styling functionality (colors, sizes, underlines, rules, bold, italic, etc.)
  2. Output to HTML (static or interactive w/ filtering, etc), LaTeX, Typst, PNG, markdown (grid and gfm), and (limited) word.

Here's a gist with the code I used:

https://gist.github.com/vincentarelbundock/d81251cea8ed99ffd3f40546b4ab663b

And here is the rendered HTML:

https://arelbundock.com/rtables_examples.html

Here is a simple example:

library(tinytable)
library(rtables)
source("rtables_to_tinytable.R")
lyt1 <- basic_table(
  title = "Summary Statistics by Treatment Arm",
  main_footer = "Data from clinical trial") %>%
  split_cols_by("ARM") %>%
  analyze("AGE", function(x) {
    in_rows("Mean" = mean(x), "SD" = sd(x), "N" = length(x), .formats = c("xx.x", "xx.x", "xx"))
  })

tbl1 <- build_table(lyt1, ex_adsl)

# Convert to tinytable using tt()
tt(tbl1) %>%
  style_tt(i = 1, bold = TRUE, color = "white", background = "#2C5F8D", fontsize = 1.3) %>%
  style_tt(i = 2:3, background = c("lightgrey", "lightblue"))
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions