The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Constructing rtables Manually

Adrian Waddell

2024-09-20

manual_table_construction.R

Overview

The main functions currently associated with rtables are

Tables in rtables can be constructed via the layout or rtabulate tabulation frameworks or also manually. Currently manual table construction is the only way to define column spans. The main functions for manual table constructions are:

Simple Example

library(rtables)

manual_table_construction.R

tbl <- rtable(
  header = c("Treatement\nN=100", "Comparison\nN=300"),
  format = "xx (xx.xx%)",
  rrow("A", c(104, .2), c(100, .4)),
  rrow("B", c(23, .4), c(43, .5)),
  rrow(),
  rrow("this is a very long section header"),
  rrow("estimate", rcell(55.23, "xx.xx", colspan = 2)),
  rrow("95% CI", indent = 1, rcell(c(44.8, 67.4), format = "(xx.x, xx.x)", colspan = 2))
)

manual_table_construction.R

Before we go into explaining the individual components used to create this table we continue with the html conversion of the rtable() object:

as_html(tbl, width = "80%")

Treatement Comparison
N=100 N=300
A 104 (20.00%) 100 (40.00%)
B 23 (40.00%) 43 (50.00%)
this is a very long section header
estimate 55.23
95% CI (44.8, 67.4)

manual_table_construction.R

Next, the [ operator lets you access the cell content.

tbl[1, 1]
#      Treatement 
#        N=100    
# ————————————————
# A   104 (20.00%)

manual_table_construction.R

and to format that cell run format_rcell(tbl[1,1])=.

Note that tbl[6, 1] and tbl[6, 2] display both the same rcell because of the colspan.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.