Purpose

When presenting tables in an HTML Rmarkdown report, it is more common to have all tables styled in the same manner. This is an example of all tables having the same style, with a few overridden styles.

This package is meant to implement the concept of a grammar of tables. It allows for a simple formula expression and a data frame to create a rich summary table in a variety of formats. It is designed for extensibility at each step of the process, so that one is not limited by the authors choice of table statistics, output format. The grammar however is an integral part of the package, and as such is not modifiable.

Supposed that further in addition to the lancet style one really wanted a shade of cyan to make the document pop. This was added to the header of this document to make all this magic happen:

 <style type="text/css">
 \```{r, results='asis'}
 cat(custom_css("lancet.css"))
 ```
 .figbody thead
 {
   background: #aaffff !important;
 }
 .figbody tbody .odd
 {
   background: #aaffff !important;
 }
 </style>

Here’s an example similary to summaryM from Hmisc to get us started:

Table 1

html5(tangram("drug ~ bili[2] + albumin + stage::Categorical + protime + sex + age + spiders", pbc),
      fragment=TRUE, caption = "Hmisc::PBC", id="tbl2")
Hmisc::PBC
ND-penicillamineplacebonot randomizedTest Statistic
154158106
Serum Bilirubin 4180.701.303.600.801.403.220.701.403.12F2,415 = 0.03,P = 0.9721
Albumin 4183.343.543.783.213.563.833.123.473.73F2,415 = 2.13,P = 0.1201
Histologic Stage, Ludwig Criteria412χ2
6
=
5.33,
P = 0.5022
    10
.
026
2.597 4154
0
.
076
7.595 12158
0
.
047
4.717 5106
    20
.
208
20.779 32154
0
.
222
22.152 35158
0
.
236
23.585 25106
    30
.
416
41.558 64154
0
.
354
35.443 56158
0
.
330
33.019 35106
    40
.
351
35.065 54154
0
.
348
34.810 55158
0
.
330
33.019 35106
Prothrombin Time 41610.010.611.410.010.611.010.110.611.0F2,413 = 0.23,P = 0.7951
sex : female4180
.
903
90.260139154
0
.
867
86.709137158
0
.
925
92.453 98106
χ2
2
=
2.38,
P = 0.3042
Age41841.448.155.842.951.959.046.053.061.1F2,415 = 6.10,P = 0.0021
spiders : present3120
.
292
29.221 45154
0
.
285
28.481 45158
χ2
1
=
0.02,
P = 0.8852
N is the number of non-missing value. 1Kruskal-Wallis test. 2Pearson test

Table 2

x <- round(rnorm(375, 79, 10))
y <- round(rnorm(375, 80,  9))
y[rbinom(375, 1, prob=0.05)] <- NA
attr(x, "label") <- "Global score, 3m"
attr(y, "label") <- "Global score, 12m"
html5(tangram(1 ~ x+y,
                    data.frame(x=x, y=y),
                    after=hmisc_intercept_cleanup),
      fragment=TRUE, caption="Intercept", id="tbl5")
Intercept
NAll
Global score, 3m375727986
Global score, 12m374748085
N is the number of non-missing value. 1Kruskal-Wallis test. 2Pearson test