Tables

Both of the examples below are taken from @MSMB.

Main body tables

We have have tables in the main body of the text, as seen below in Table \@ref(tab:main-table). Following the tufte convention the caption appears alongside in the margin.

d1 <- t(data.frame(
    quiet = c(2770, 2150, 2140, 875, 1220, 821, 2510),
    angry = c(2970, 1530, 1740, 752, 1040, 710, 1730),
    clever = c(1650, 1270, 1320, 495, 693, 416, 1420),
    depressed = c(1480, 957, 983, 147, 330, 102, 1270),
    happy = c(19300, 8310, 8730, 1920, 4220, 2610, 9150),
    lively = c(1840, 1250, 1350, 659, 621, 488, 1480),
    perplexed = c(110,  71,  80,  19,  23,  15, 109),
    virtuous = c(179,  80, 102,  20,  25,  17, 165)))
colnames(d1) <- c('black','blue','green','grey','orange','purple','white')
knitr::kable(d1, caption = 'Example of table appearing in the main body of the text.')

Margin tables

You can also include tables in the margin column as in Table \@ref(tab:margin-table), with the caption above.

HIV <- data.frame(Patient = c('AHX112', 'AHX717', 'AHX543'), 
                           Mut1 = c(0, 1, 1),
                           Mut2 = c(0, 0, 0),
                           Mut3 = c(0, 1, 0),
                           '...' = rep(' ', 3))
knitr::kable(HIV, format = 'html', table.attr = 'class=\"margintab marginnote\"',
        caption = 'An example of a table in the margin.')

To achieve this we use the kable() function to produce the an HTML table with the attributes margintab & marginnote. msmbstyle then provides the CSS required to place this table in the margin.



grimbough/msmbstyle documentation built on April 9, 2022, 5:09 p.m.