SummaryTables

SummaryTables is focused on creating tables for publications in LaTeX, docx and HTML formats. It offers both convenient predefined table functions that are inspired by common table formats in the pharma space, as well as an API to create completely custom tables.

It deliberately uses an opinionated, limited styling API so that styling can be as consistent as possible across the different backends.

using SummaryTables
using DataFrames

data = DataFrame(
    sex = ["m", "m", "m", "m", "f", "f", "f", "f", "f", "f"],
    age = [27, 45, 34, 85, 55, 44, 24, 29, 37, 76],
    blood_type = ["A", "0", "B", "B", "B", "A", "0", "A", "A", "B"],
    smoker = [true, false, false, false, true, true, true, false, false, false],
)

table_one(
    data,
    [:age => "Age (years)", :blood_type => "Blood type", :smoker => "Smoker"],
    groupby = :sex => "Sex",
    show_n = true
)
Sex
Overall
(n=10)
f
(n=6)
m
(n=4)
Age (years)
Mean (SD) 45.6 (20.7) 44.2 (19.1) 47.8 (25.9)
Median [Min, Max] 40.5 [24, 85] 40.5 [24, 76] 39.5 [27, 85]
Blood type
0 2 (20%) 1 (16.7%) 1 (25%)
A 4 (40%) 3 (50%) 1 (25%)
B 4 (40%) 2 (33.3%) 2 (50%)
Smoker
false 6 (60%) 3 (50%) 3 (75%)
true 4 (40%) 3 (50%) 1 (25%)
using DataFrames
using SummaryTables
using Statistics

data = DataFrame(
    concentration = [1.2, 4.5, 2.0, 1.5, 0.1, 1.8, 3.2, 1.8, 1.2, 0.2],
    id = repeat([1, 2], inner = 5),
    time = repeat([0, 0.5, 1, 2, 3], 2)
)

listingtable(
    data,
    :concentration => "Concentration (ng/mL)",
    rows = :id => "ID",
    cols = :time => "Time (hr)",
    summarize_rows = [
        length => "N",
        mean => "Mean",
        std => "SD",
    ]
)
Time (hr)
0 0.5 1 2 3
ID Concentration (ng/mL)
1 1.2 4.5 2 1.5 0.1
2 1.8 3.2 1.8 1.2 0.2
N 2 2 2 2 2
Mean 1.5 3.85 1.9 1.35 0.15
SD 0.424 0.919 0.141 0.212 0.0707
using DataFrames
using SummaryTables
using Statistics

data = DataFrame(
    concentration = [1.2, 4.5, 2.0, 1.5, 0.1, 1.8, 3.2, 1.8, 1.2, 0.2],
    id = repeat([1, 2], inner = 5),
    time = repeat([0, 0.5, 1, 2, 3], 2)
)

summarytable(
    data,
    :concentration => "Concentration (ng/mL)",
    cols = :time => "Time (hr)",
    summary = [
        length => "N",
        mean => "Mean",
        std => "SD",
    ]
)
Time (hr)
0 0.5 1 2 3
Concentration (ng/mL)
N 2 2 2 2 2
Mean 1.5 3.85 1.9 1.35 0.15
SD 0.424 0.919 0.141 0.212 0.0707