pharmaverse / pharmaverse/rtables

`tinytable`

Open
#1,070 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
260
Forks
53
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the proposed tt.rtables() S3 method and the conversion example in rtables_to_tinytable.R, then compare the proof-of-concept behavior with the existing rtables table-building flow. Done means rtables tables can be converted through tinytable with the demonstrated styling and output support, with the relevant behavior validated in the repository's tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.