11 November 2026, brought up to date on 14 November
What the book found for 0.2
The tabelline book ported 25 chapters for 0.2: release posts, gt's articles, Great Tables' examples, entries of the Table Contest. They found 47 things tabelline could not do yet, in two rounds: 15 while 0.2 was built, 29 more before the tag, 3 left for later.
The tabelline book takes pages written for gt and Great Tables and makes every table again in Nim, next to the original R and Python. Each page asks tabelline for what a user asks, in the order a user meets it, so the book is the test that no spec writes. For 0.1 it found two bugs and a dozen gaps (What the book found for 0.1). For 0.2 it went further: from a guide to release posts, then to articles that build a whole table, as someone would at work, and last to tables other people made, for the Table Contest. The release waited for it.
It came in two rounds. The first, on 11 November, ported eight chapters while 0.2 was built, and its fifteen findings went into 0.2 as they were found. The second, on 13 November, ported seventeen more; its findings were first written down as gaps for a later release, and Pietro answered: that is indeed why we update the book before release. So 0.2 waited again, and 29 of the 32 were built before the tag. This post was first written after the first round; it now tells both.
It goes from the simplest to the most complex: what the book ported, the list of what it found, then each finding told on its own, in the order a table is made, and last how the work was done.
What the book ported
The first round: eight chapters
Eight new chapters in three sections, each with R, Python and Nim.
| What it shows | |
|---|---|
| Great Tables: Get Started | |
| Nanoplots | line, bar and box plots in a cell; reference lines and areas; x and y pairs |
| Great Tables: the blog | |
| Introducing Great Tables | the parts of a table, formats, styles, the stub |
| v0.2.0: Easy Data Coloring | dataColor on populations |
| v0.3.0: So Many Style Options! | column widths, options, images, font stacks |
| v0.4.0: Nanoplots and More | nanoplots from lists of values; the Paris Metro |
| gt: articles | |
| Creating Summary Lines | summary rows, grand summary rows, their formats and locations |
| Case Study: gtcars | one table built step by step, merges with HTML, footnotes |
| Case Study: Clinical Tables | a demographic summary, event rates, protocol deviations |
type Ported = object
section, chapter, source, shows: string
let rows = @[
Ported(section: "Great Tables: Get Started", chapter: "[Nanoplots](../../book/get-started/nanoplots.html)",
source: "Great Tables' guide",
shows: "line, bar and box plots in a cell; reference lines and areas; *x* and *y* pairs"),
Ported(section: "Great Tables: the blog", chapter: "[Introducing Great Tables](../../book/blog/introducing.html)",
source: "Great Tables' blog", shows: "the parts of a table, formats, styles, the stub"),
Ported(section: "Great Tables: the blog", chapter: "[v0.2.0: Easy Data Coloring](../../book/blog/v0_2.html)",
source: "Great Tables' blog", shows: "`dataColor` on populations"),
Ported(section: "Great Tables: the blog", chapter: "[v0.3.0: So Many Style Options!](../../book/blog/v0_3.html)",
source: "Great Tables' blog", shows: "column widths, options, images, font stacks"),
Ported(section: "Great Tables: the blog", chapter: "[v0.4.0: Nanoplots and More](../../book/blog/v0_4.html)",
source: "Great Tables' blog", shows: "nanoplots from lists of values; the Paris Metro"),
Ported(section: "gt: articles", chapter: "[Creating Summary Lines](../../book/vignettes/summary_lines.html)",
source: "gt's documentation", shows: "summary rows, grand summary rows, their formats and locations"),
Ported(section: "gt: articles", chapter: "[Case Study: gtcars](../../book/vignettes/case_study_gtcars.html)",
source: "gt's documentation", shows: "one table built step by step, merges with HTML, footnotes"),
Ported(section: "gt: articles", chapter: "[Case Study: Clinical Tables](../../book/vignettes/case_study_clinical.html)",
source: "gt's documentation", shows: "a demographic summary, event rates, protocol deviations")]
let t = tabella(rows, rownameCol = "chapter", groupnameCol = "section"):
colsHide "source"
colsLabel:
shows: "What it shows"
fmtMarkdown ["chapter", "shows"]
optCssTheme()
nbTable tThe last three are the first sources written in R. gt's articles are longer than a guide's page: the clinical tables case study builds three tables, each in a dozen steps, from data it first counts, groups and pivots. The Python tab is written for the book, the way Great Tables would make the same table.
Before the tag: seventeen more
The second round finished the Great Tables blog, added Great Tables' own examples, one page of gt-extras, gt's article on its datasets, and six entries of the Table Contest: tables people made with gt and Great Tables for a contest, with data and choices of their own.
| What it shows | |
|---|---|
| Great Tables: the blog | |
| Using Polars to Win at Super Bowl Squares | a grid of chances coloured by value |
| The Design Philosophy of Great Tables | the parts of a table, one at a time |
| Great Tables for Scientific Publishing | units, scientific notation, nanoplots |
| v0.12.0: Google Fonts and zebra stripes | font stacks and stripes |
| v0.13.0: Applying styles to all table locations | styles on every part, Markdown for missing values |
| v0.15.0: Flags, Icons, and Other Formatting Goodies | flags, icons, accounting |
| v0.18.0: Easy Column Spanners and More! | spanners from names, columns by kind, datetimes |
| Recreating Septa Transit Timetables in Python | a timetable as wide as a wall |
| Great Tables: examples | |
| Examples | the gallery of Great Tables' home page |
| Sports earnings | a ranking with images and HTML |
| gt-extras | |
| An NFL season | bars, ratings and logos made with plain formats |
| gt: articles | |
| gt Datasets | every dataset of gt, as a table |
| The Table Contest | |
| Euro NCAP Safety Ratings - 2023 | ratings as stars and bars |
| Lemurs at Duke Lemur Center | pictures, groups, aligned text |
| Mapping the Latin American Pharmaceutical Landscape | flags and colour by value |
| Titanic Challenge | counts and percents side by side |
| Basic gt Styling Reference | every style of a cell, one per row |
| Periodic table of elements | a table laid out as a picture |
type Ported = object
section, chapter, shows: string
let later = @[
Ported(section: "Great Tables: the blog", chapter: "[Using Polars to Win at Super Bowl Squares](../../book/blog/superbowl.html)",
shows: "a grid of chances coloured by value"),
Ported(section: "Great Tables: the blog", chapter: "[The Design Philosophy of Great Tables](../../book/blog/design.html)",
shows: "the parts of a table, one at a time"),
Ported(section: "Great Tables: the blog", chapter: "[Great Tables for Scientific Publishing](../../book/blog/scientific.html)",
shows: "units, scientific notation, nanoplots"),
Ported(section: "Great Tables: the blog", chapter: "[v0.12.0: Google Fonts and zebra stripes](../../book/blog/v0_12.html)",
shows: "font stacks and stripes"),
Ported(section: "Great Tables: the blog", chapter: "[v0.13.0: Applying styles to all table locations](../../book/blog/v0_13.html)",
shows: "styles on every part, Markdown for missing values"),
Ported(section: "Great Tables: the blog", chapter: "[v0.15.0: Flags, Icons, and Other Formatting Goodies](../../book/blog/v0_15.html)",
shows: "flags, icons, accounting"),
Ported(section: "Great Tables: the blog", chapter: "[v0.18.0: Easy Column Spanners and More!](../../book/blog/v0_18.html)",
shows: "spanners from names, columns by kind, datetimes"),
Ported(section: "Great Tables: the blog", chapter: "[Recreating Septa Transit Timetables in Python](../../book/blog/septa.html)",
shows: "a timetable as wide as a wall"),
Ported(section: "Great Tables: examples", chapter: "[Examples](../../book/examples/examples.html)",
shows: "the gallery of Great Tables' home page"),
Ported(section: "Great Tables: examples", chapter: "[Sports earnings](../../book/examples/sports_earnings.html)",
shows: "a ranking with images and HTML"),
Ported(section: "gt-extras", chapter: "[An NFL season](../../book/extras/nfl_season.html)",
shows: "bars, ratings and logos made with plain formats"),
Ported(section: "gt: articles", chapter: "[gt Datasets](../../book/vignettes/gt_datasets.html)",
shows: "every dataset of gt, as a table"),
Ported(section: "The Table Contest", chapter: "[Euro NCAP Safety Ratings - 2023](../../book/contest/euroncap.html)",
shows: "ratings as stars and bars"),
Ported(section: "The Table Contest", chapter: "[Lemurs at Duke Lemur Center](../../book/contest/lemurs.html)",
shows: "pictures, groups, aligned text"),
Ported(section: "The Table Contest", chapter: "[Mapping the Latin American Pharmaceutical Landscape](../../book/contest/latam_pharma.html)",
shows: "flags and colour by value"),
Ported(section: "The Table Contest", chapter: "[Titanic Challenge](../../book/contest/titanic.html)",
shows: "counts and percents side by side"),
Ported(section: "The Table Contest", chapter: "[Basic gt Styling Reference](../../book/contest/gt_styling.html)",
shows: "every style of a cell, one per row"),
Ported(section: "The Table Contest", chapter: "[Periodic table of elements](../../book/contest/periodic_table.html)",
shows: "a table laid out as a picture")]
let second = tabella(later, rownameCol = "chapter", groupnameCol = "section"):
colsLabel:
shows: "What it shows"
fmtMarkdown ["chapter", "shows"]
optCssTheme()
nbTable secondWith the first round, that is 25 chapters, 12 of them posts of the Great Tables blog, and the book has a page that finds an example by feature.
What the book found
The first round: fifteen
Every line the book could not write in tabelline became a finding, sent to the build of 0.2 as it was found. Thirteen went into 0.2. Three of those were still open when this post was first written (every colour name, a table in one step, data frames); Pietro asked for them too, so nothing this port found is left open. Two findings stay as differences, on purpose.
The list goes from the simplest step of making a table to the most complex, as the list of gaps does. Each finding links to its story below; Found in is the chapter that found it.
| Step | Found in | Now | |
|---|---|---|---|
| Built in 0.2 | |||
| gt's datasets in tabelline | Data | the blog | tabelline/datasets: gtcars(), countrypops(), illness(), metro() |
| A cell with many values | Data | Nanoplots | lists and records in a cell |
| Data frames | Data | Clinical Tables | tabella(df) for nanuq, import tabelline/nanuq |
| A row's columns with a dot | Rows | every chapter | it.Temp |
| Columns by position, and rules joined | Columns | Clinical Tables | positions(0, -1); a + b; startsWith(["pct_", "ci_"]) |
| Spanners that gather their columns | Columns | Clinical Tables | tabSpanner gathers, as gt's does |
| Line breaks in Markdown | Text | Clinical Tables | two spaces, or a backslash, before a newline |
| Summary rows of one label in one row | Summaries | Summary Lines | one row, as in gt |
| Summary values, not only text | Summaries | Summary Lines | extractSummary(t, values = true) |
| A nanoplot point by point | Formats | Nanoplots | an option for each point; dates on x |
| Font stacks by name | Options | v0.3.0 | systemFonts("industrial") |
| Every CSS colour name | Styles | v0.2.0 | 148 names, "darkgreen" too |
| A table in one step | Notebooks | every chapter | nbTable data: body |
| Kept as a difference | |||
| Aggregates skip missing values | Summaries | Summary Lines | as Polars does; gt needs na.rm = TRUE |
| A summary cell takes its column's format | Summaries | Summary Lines | unless fmt says otherwise |
type Finding = object
outcome, step, title, where, now: string
let clinical = "[Clinical Tables](../../book/vignettes/case_study_clinical.html)"
let summaryLines = "[Summary Lines](../../book/vignettes/summary_lines.html)"
let nanoplots = "[Nanoplots](../../book/get-started/nanoplots.html)"
let built = "Built in 0.2"
let kept = "Kept as a difference"
let findings = @[
Finding(outcome: built, step: "Data", title: "gt's datasets in tabelline",
where: "[the blog](../../book/blog/index.html)", now: "`tabelline/datasets`: `gtcars()`, `countrypops()`, `illness()`, `metro()`"),
Finding(outcome: built, step: "Data", title: "A cell with many values",
where: nanoplots, now: "lists and records in a cell"),
Finding(outcome: built, step: "Data", title: "Data frames",
where: clinical, now: "`tabella(df)` for nanuq, `import tabelline/nanuq`"),
Finding(outcome: built, step: "Rows", title: "A row's columns with a dot",
where: "every chapter", now: "`it.Temp`"),
Finding(outcome: built, step: "Columns", title: "Columns by position, and rules joined",
where: clinical, now: "`positions(0, -1)`; `a + b`; `startsWith([\"pct_\", \"ci_\"])`"),
Finding(outcome: built, step: "Columns", title: "Spanners that gather their columns",
where: clinical, now: "`tabSpanner` gathers, as gt's does"),
Finding(outcome: built, step: "Text", title: "Line breaks in Markdown",
where: clinical, now: "two spaces, or a backslash, before a newline"),
Finding(outcome: built, step: "Summaries", title: "Summary rows of one label in one row",
where: summaryLines, now: "one row, as in gt"),
Finding(outcome: built, step: "Summaries", title: "Summary values, not only text",
where: summaryLines, now: "`extractSummary(t, values = true)`"),
Finding(outcome: built, step: "Formats", title: "A nanoplot point by point",
where: nanoplots, now: "an option for each point; dates on *x*"),
Finding(outcome: built, step: "Options", title: "Font stacks by name",
where: "[v0.3.0](../../book/blog/v0_3.html)", now: "`systemFonts(\"industrial\")`"),
Finding(outcome: built, step: "Styles", title: "Every CSS colour name",
where: "[v0.2.0](../../book/blog/v0_2.html)", now: "148 names, `\"darkgreen\"` too"),
Finding(outcome: built, step: "Notebooks", title: "A table in one step",
where: "every chapter", now: "`nbTable data: body`"),
Finding(outcome: kept, step: "Summaries", title: "Aggregates skip missing values",
where: summaryLines, now: "as Polars does; gt needs `na.rm = TRUE`"),
Finding(outcome: kept, step: "Summaries", title: "A summary cell takes its column's format",
where: summaryLines, now: "unless `fmt` says otherwise")]
# each title links to its section below
var rows = findings
for f in rows.mitems: f.title = "[" & f.title & "](#" & slugify(f.title) & ")"
let t = tabella(rows, rownameCol = "title", groupnameCol = "outcome"):
colsLabel:
step: "Step"
title: "Finding"
where: "Found in"
now: "Now"
fmtMarkdown ["title", "where", "now"]
optCssTheme()
nbTable tThree of them were findings of 0.1 that came back: columns by position, column rules joined and spanners that gather their columns. The 0.1 port had found them in small examples and left them for later. The case studies needed each of them, and wrote a line of Nim around it. A gap that a real table works around is worth more than one a guide mentions, so 0.2 closed them.
Before the tag: twenty-nine more
The second round found 32 more. Pietro chose to build all but three before the tag. Here are the 29, in the order of the list of gaps, which this table reads, and Where it shows is the chapter that uses it now.
| Where it shows | |
|---|---|
| Data | |
Text with a zero in front ("0400") stays text when a CSV is read, as pandas keeps it | Colorizing with Data |
| A list column of a nanuq data frame (a nanoplot's values) becomes a list in the table | Examples |
| Parts | |
tabStub, the stub (and the groups) of a table already made, as Great Tables' tab_stub() | Stub, Examples, SEPTA timetables |
tabRowGroup(label, id = ...) relabels a group, with Markdown (a link) too | Find an example by feature |
| Columns | |
A block of colsLabel mixes plain labels with html/md ones | SEPTA timetables |
ofKind(vkBool), columns by the kind of their values, as cs.by_dtype(pl.Boolean) | v0.18.0 |
named(cond) and matches(proc), columns by any test of the name; a & b, the columns two rules share | Column Selection, SEPTA timetables |
| Rows | |
Negative row indices, from the end (-1, or Nim's ^1) | Row Selection, SEPTA timetables |
| Formats | |
accounting in fmtNumber, fmtInteger and fmtPercent | v0.15.0 |
Significant figures, nSigfig, in fmtNumber, also with compact | Examples |
fmtDatetime(formatStr = "%b %d %Y"), a datetime by a strftime format | v0.18.0 |
Markdown in subMissing's text, md"**STABLE**" | v0.13.0 |
fmtFlag: the country's name on hover, and Great Tables' round flags (round = true) | v0.15.0 |
The format functions take the arguments of their verbs: pattern, locale, expStyle, accounting, nSigfig | Formatting Values, Creating Summary Lines |
| Text | |
Fuller Markdown in md(): HTML entities, _ and __, ~~struck~~, <https://...>, paragraphs and lists | Header and Footer |
| Options | |
| Light text on a dark stub, row group or summary row, as on the heading and the column labels | Table Theme Options |
optStylize with gt's six styles, in its six colours | Premade Themes |
optAllCaps on the stub and the row group labels too, or on the locations named | Premade Themes, v0.3.0 |
| Styles | |
style.text(vAlign = ...) | v0.13.0, Lemurs, Basic gt Styling Reference |
style.text(indent = ...) and style.fill(alpha = ...) | Basic gt Styling Reference |
loc.stub(labels = ["banana"]), rows by their label, with indices too | Location selection |
loc.rowGroups(rows = ...), the groups of some rows, by index or by a condition | Location selection |
loc.body(mask = ...): a test for each cell, of its value and its column | Styling the Table Body, Location selection |
| A fill on a spanner colours its whole cell | Styling the whole table |
dataColor leaves the stub alone, as Great Tables does | Super Bowl Squares |
R's 657 colour names (sienna4, chartreuse3), which gt and Great Tables take | Examples |
palette("great-tables"), Great Tables' default palette for dataColor (tabelline keeps blues as its own) | Colorizing with Data |
| Look | |
Formatted numbers do not break inside a cell (−$24,334.23, 1.63 × 10⁻²) | v0.15.0, v0.13.0 |
stubSticky = true: the stub stays in view while a wide table scrolls sideways (not in gt) | SEPTA timetables |
type Gap = object
step, what, where: string
var gaps: seq[Gap]
var inRound = false
for line in readFile(docs.parentDir / "book" / "gaps.md").splitLines:
if "Text with a zero in front" in line: inRound = true
if inRound and line.startsWith("| "):
let cells = line.strip(chars = {'|', ' '}).split(" | ")
gaps.add Gap(step: cells[0], what: cells[1],
where: cells[2].replace("](", "](../../book/"))
if "stubSticky" in line: inRound = false
let round2 = tabella(gaps, rownameCol = "what", groupnameCol = "step"):
colsLabel:
where: "Where it shows"
fmtMarkdown ["what", "where"]
optCssTheme()
nbTable round2Most are small: an argument gt has and tabelline did not, a name that Great Tables takes. They
are the kind a guide never meets, because each page of a guide shows one thing; a real table
meets them all at once. Three stay open, by Pietro's choice: saving a table as an image (gt's
gtsave()), which is the next release, Out of the browser; a small chart in each row drawn
from other data (gt's ggplot_image(), gt-extras' plots), which a proc of your own already
draws through fmt; and the book's own helpers for pandas' head, select and loc, which
nanuq has and the chapters will move to.
The first round, one by one
Each finding in three parts: what the book wanted to write, what gt and Great Tables do, and what tabelline does now.
gt's datasets in tabelline
The Great Tables blog posts make their tables from gt's datasets: gtcars for the cars of the
v0.3.0 post, countrypops for v0.2.0, illness and metro for v0.4.0. tabelline had only its
own (planets, exibble, isole, citta), so the book read copies of the CSV files from a
helper of its own. gt has them in R and Great Tables in Python, so a reader of either can try any
example at once. Now tabelline has them too, with gt's licence:
import tabelline, tabelline/datasets
let t = tabella(gtcars(), rownameCol = "model"):
colsHide ["trim", "bdy_style"]
A cell with many values
The finding that changed tabelline the most came from the last example of the Nanoplots page.
Great Tables draws a scatter in a cell from a Polars struct: a dictionary with a list of x
and a list of y. tabelline's cells held one value each, so the book could show that example
only in Python and R. gt keeps one value per cell too, and its cols_nanoplot() reads several
columns. The question went from the book to Pietro: how should Nim say it? The answer is two
new kinds of value. A list is a cell of values (@[1.0, 4, 2]), and a record is a cell of named
values, a Nim tuple, read with a dot like a field (v.x). A format applies to each item.
The book's example, now in Nim:
let weather = tableData:
station: ["Station 1", "Station 2", "Station 3"]
temperatures: [
(x: @[6.1, 8.0, 10.1, 10.5, 11.2, 12.4, 13.1, 15.3],
y: @[24.2, 28.2, 30.2, 30.5, 30.5, 33.1, 33.5, 32.7]),
(x: @[7.1, 8.2, 10.3, 10.75, 11.25, 12.5, 13.5, 14.2],
y: @[18.2, 18.1, 20.3, 20.5, 21.4, 21.9, 23.1, 23.3]),
(x: @[6.3, 7.1, 10.3, 11.0, 12.07, 13.1, 15.12, 16.42],
y: @[15.2, 17.77, 21.42, 21.63, 25.23, 26.84, 27.2, 27.44])]
let scatter = tabella(weather):
fmtNanoplot "temperatures", plotType = "line",
expandX = @[5.0, 16.0], expandY = @[10.0, 40.0],
options = nanoplotOptions(showDataArea = false, showDataLine = false)
optCssTheme()
nbTable scatter
| station | temperatures |
|---|---|
| Station 1 | |
| Station 2 | |
| Station 3 |
Each cell of temperatures is a record, a tuple with the fields x and y. fmtNanoplot
places each y at its x, and expandX and expandY give every plot the same scale.
Data frames
The case studies start from raw data: one row for each subject of a trial. Before gt sees it, R
counts the subjects of each arm, groups, summarises and pivots with dplyr and tidyr, and Great
Tables takes a Polars or pandas DataFrame as it is, GT(df). tabelline makes tables, not data,
and Nim's standard library has no data frames, so the book first wrote those steps in plain Nim:
rows as OrderedTables, a loop for each arm of the trial, about fifty lines for the demographic
summary. The answer is not inside tabelline: it is to take the data frames Nim has.
import tabelline/nanuq makes tabella(df) work for a DataFrame of
nanuq, Polars for Nim, and the case study now counts and
pivots as R does:
import nanuq
import tabelline, tabelline/nanuq
let bySex = subjects
.groupBy("TRTA", "SEX")
.agg(len().alias("val"))
.withColumns((col("val") / col("val").sum.over("TRTA")).alias("pct"))
.pivot("TRTA", index = "SEX", values = ["val", "pct"])
let t = tabella(bySex, rownameCol = "SEX"):
fmtPercent startsWith("pct_"), decimals = 1
It is an optional module: the core of tabelline still needs only Nim's standard library, and
only a program that imports tabelline/nanuq downloads nanuq's Polars library (about 50 MB, once).
One step stays in Nim: neither Nim's standard library nor nanuq has the quantiles of the F
distribution that R's Clopper-Pearson interval uses, so the book finds the interval from the
binomial probabilities, by bisection, and its numbers match R's.
A row's columns with a dot
Every condition on a row was written with brackets, where(it["Temp"] > 80). gt reads the column
by its name (Temp > 80) and Great Tables with a Polars expression (pl.col("Temp") > 80); in
Nim the brackets were the noise of every chapter. With records came the dot, and the same dot
reads a row's columns:
let hot = tabella(weatherDays):
tabStyle style.fill("var(--warning-soft)"), loc.body(rows = where(it.Temp > 80))
A name the row already has (kind, len, index) or a word of Nim (type) still takes the
brackets: it["type"].
Columns by position, and rules joined
The clinical tables align the first column by its place, cols_align(columns = 1), and format
several groups of columns with one rule, starts_with(c("val_", "min_", "max_")). Great Tables
does the same with columns=0 and Polars' selectors (cs.starts_with("val_", "min_")).
tabelline took names or one rule, so the book named the first column and wrote a helper that
listed the names. Now:
colsAlign alLeft, positions(0) # 0 is the first, -1 the last
fmtInteger startsWith(["val_", "min_", "max_"]) # in brackets: several prefixes
colsHide startsWith("ci_") + endsWith("_up") # a + b: either; a - b: a but not b
Positions count from 0, as in Python; gt counts from 1.
Spanners that gather their columns
gt's tab_spanner() moves the columns it spans next to the first one, in the order given
(gather = TRUE). tabelline left them where they were, so a spanner over columns that are not
side by side could not be drawn, and the clinical tables moved each column by hand first
(colsMove). Now tabSpanner gathers them, as gt does, and gather = false leaves them where
they are:
tabSpanner "Placebo", cols("n_resp_Placebo", "ci_low_Placebo")
Line breaks in Markdown
The protocol deviations table puts three lines in a spanner, each arm with its size:
md("Placebo \n N=90 (100%) \n n (%)"). In Markdown two spaces before a newline break the
line, and gt draws three lines. tabelline's md joined them into one. Now two spaces, or a
backslash, before a newline break the line.
Summary rows of one label in one row
Creating Summary Lines calls summary_rows() twice, once for num and once for currency, both
with a row labelled avg. gt squashes them into one row avg with both cells; Great Tables adds
a row for each call, and so did tabelline. Now two calls with the same label make one row, as in
gt:
summaryRows fnsLabels, columns = "num"
summaryRows fnsLabels, columns = "currency" # the same rows, now with currency too
Summary values, not only text
gt's extract_summary() gives the summary rows as data, to check them or to make a new table
from them, formatted again. Great Tables has no such function. tabelline's extractSummary gave
the cells as shown (2.926 × 10²), which cannot be formatted again. Now values = true gives
the numbers:
let standalone = tabella(extractSummary(t, values = true), rownameCol = "label"):
fmtNumber "num", decimals = 1
A nanoplot point by point
Great Tables' nanoplot_options() takes one value for every point, or a list with a value for
each point (a colour, a size), and the x values of a plot can be dates. tabelline took one
value only, and numbers. Now each option of points and bars takes a value or a list, and x
takes ISO dates ("2026-11-11"), placed by time:
nanoplotOptions(dataPointFillColor = @["white", "white", "red"])
Font stacks by name
The v0.3.0 post sets a table's font to a stack, fonts that are on most systems, by name:
system_fonts("industrial") in Great Tables, opt_table_font(stack = "industrial") in gt.
tabelline had no names, so the book wrote the stack out, font by font. Now systemFonts knows
Great Tables' fifteen stacks:
tabOptions tableFontNames = systemFonts("industrial")
Every CSS colour name
The v0.2.0 post colours the cells of currency from light blue to
dark green, with a palette of two names:
GT(exibble_mini).data_color(columns="currency", palette=["lightblue", "darkgreen"])
The same line in tabelline stopped with ValueError: not a colour: darkgreen. A plain fill
(style.fill("darkgreen")) works, because the name goes to the browser as it is. But
dataColor computes the colours in between, and the choice of white or dark text on each cell:
for that tabelline needs the red, green and blue of each colour, and it knew them for 17 names.
Great Tables knows every name of CSS, and gt every name of R (R lacks rebeccapurple). Now
tabelline knows the 148 names of CSS, checked against a browser, and a dark heading given by
name gets white text too:
dataColor "currency", palette = @["lightblue", "darkgreen"]
A table in one step
Every chapter, and every page of this site, named a table before showing it:
let t = tabella(planets()):
tabHeader "Planets"
nbTable t
The shorter form, nbTable tabella(planets()): tabHeader "Planets", does not compile: Nim gives
the indented body to nbTable, the outer call, and not to tabella. A notebook in R or Python
has no such step, because it shows the last value of a cell. Now nbTable takes the data and
the body itself, with tabella's other arguments:
nbTable planets(), rownameCol = "planet":
tabHeader "Planets"
When the code is shown on the page, as in the book, naming the table still reads best; the short form is for a table whose code is not shown.
Two differences kept
Aggregates skip missing values
In Creating Summary Lines, grp_b has a missing num. gt's mean() then gives NA, shown as a
dash, and the article's next example writes ~ mean(., na.rm = TRUE) to get a number. Polars
skips missing values, so Great Tables gives the number at once, and so does tabelline: agg.mean,
agg.sum and the others leave missing values out. A summary of the numbers a reader sees is what
a table means, and an aggregate of your own (aggregate(proc ...)) gets every value, missing
ones too, when the missing matter.
A summary cell takes its column's format
gt formats a summary cell with fmt_number() when the call gives no fmt; Great Tables leaves it
as it is. tabelline formats it as its column, with the column's locale: one
fmtScientific "num", decimals = 3 serves the body and the summary rows, and a fmt in
summaryRows still says otherwise. It saves a line in almost every summary of the book, and a
table whose totals look like its rows reads as one.
Before the tag, one by one
Seven of the 29, from the simplest step to the most complex. Each is a small table, made here with what 0.2 has now.
A zero in front stays text
Colorizing with Data reads a CSV with true
solar times, 0530 and 1200. tabelline read them as numbers, so 0530 lost its zero. pandas
and Polars keep a column like that as text, because a number is never written with a zero in
front: codes, times and postcodes are. tabelline does too now.
let sza = parseCsv("tst,sza\n0530,84.9\n1200,\n")
echo sza["tst", 0], " is ", sza["tst", 0].kind
echo sza["sza", 0], " is ", sza["sza", 0].kind
0530 is vkString 84.9 is vkFloat
The stub of a table already made
Great Tables writes GT(df).tab_stub(rowname_col="name"), and the stub can be set after the
table is made. tabelline took the stub only when the table was made, so the
Stub chapter and SEPTA
made the table again. Now tabStub sets it, with the groups too:
let lunch = tableData:
fruit: ["apple", "banana", "cherry"]
kind: ["tree", "herb", "tree"]
price: [0.5, 0.25, 3.0]
let fruits = tabella(lunch):
tabStub "fruit", groupnameCol = "kind"
fmtCurrency "price"
optCssTheme()
nbTable fruits
| price | |
|---|---|
| tree | |
| apple | $0.50 |
| cherry | $3.00 |
| herb | |
| banana | $0.25 |
Columns by kind, by a test of the name, and rows from the end
Great Tables picks columns by their type (cs.by_dtype(pl.Boolean)) and gt by a test
(where(is.logical), matches()); the v0.18.0 post and
Column Selection use them. A row from the end is
-1 in Python and n() in gt. tabelline has all three now, and & for the columns two rules
share:
let ringed = tabella(planets(), rownameCol = "planet"):
colsHide named(it notin ["moons", "rings"])
tabStyle style.text(weight = "bold"),
loc.body(ofKind(vkBool), rows = -1)
optCssTheme()
nbTable ringed
| moons | rings | |
|---|---|---|
| Mercury | 0 | false |
| Venus | 0 | false |
| Earth | 1 | false |
| Mars | 2 | false |
| Jupiter | 95 | true |
| Saturn | 146 | true |
| Uranus | 28 | true |
| Neptune | 16 | true |
ofKind(vkBool) is the columns of Booleans, named(cond) the columns whose name it passes cond, and -1 the last row (Nim's ^1 too).
Three figures, and the minus in parentheses
The Examples show three significant figures (gt's
n_sigfig), and v0.15.0 shows money as an accountant writes it,
a loss in parentheses. Both are arguments of fmtNumber now, and accounting of fmtInteger,
fmtPercent and fmtCurrency too:
let books = tableData:
item: ["sales", "costs", "a fee"]
amount: [24334.2345, -18110.5, -0.01632]
let ledger = tabella(books, rownameCol = "item"):
fmtNumber "amount", nSigfig = 3, accounting = true
optCssTheme()
nbTable ledger
| amount | |
|---|---|
| sales | 24,300 |
| costs | (18,100) |
| a fee | (0.0163) |
gt's six styles
optStylize had one style. gt has six, each in six colours, and
Premade Themes shows them all. tabelline
has them now, with gt's colours: a premade look for a table that is not on a page of its own
style.
let styled = tabella(planets(), rownameCol = "planet", groupnameCol = "type"):
colsHide named(it notin ["moons", "mass"])
optStylize style = 6
nbTable styled
| mass | moons | |
|---|---|---|
| Terrestrial | ||
| Mercury | 0.33 | 0 |
| Venus | 4.87 | 0 |
| Earth | 5.97 | 1 |
| Mars | 0.642 | 2 |
| Gas giant | ||
| Jupiter | 1898.0 | 95 |
| Saturn | 568.0 | 146 |
| Ice giant | ||
| Uranus | 86.8 | 28 |
| Neptune | 102.0 | 16 |
A test for each cell
Great Tables' loc.body(mask=...) styles the cells that pass a Polars expression, column by
column: the largest of each column, in
Styling the Table Body. gt has no mask; it needs one
tab_style() for each column. In tabelline a mask is a proc of the cell's value and of its
column:
let largest = tabella(planets(), rownameCol = "planet"):
colsHide named(it notin ["moons", "mass", "diameter"])
tabStyle style.text(weight = "bold"),
loc.body(mask = proc (v: Value, col: Column): bool =
v == agg.max.fn(col.values))
optCssTheme()
nbTable largest
| mass | diameter | moons | |
|---|---|---|---|
| Mercury | 0.33 | 4879 | 0 |
| Venus | 4.87 | 12104 | 0 |
| Earth | 5.97 | 12756 | 1 |
| Mars | 0.642 | 6792 | 2 |
| Jupiter | 1898.0 | 142984 | 95 |
| Saturn | 568.0 | 120536 | 146 |
| Uranus | 86.8 | 51118 | 28 |
| Neptune | 102.0 | 49528 | 16 |
A stub that stays in view
SEPTA is a timetable with a column for each train. On a phone it is
wider than the screen and scrolls inside its box, and the stations scroll away with the trains.
stubSticky = true keeps the stub in view. Neither gt nor Great Tables has it: it is in the
feature map's list of what is worth porting back. Scroll this table sideways:
let wide = tabella(planets(), rownameCol = "planet"):
tabOptions:
stubSticky = true
optCssTheme()
nbTable wide
| type | mass | diameter | density | gravity | day_length | distance | orbital_period | mean_temp | moons | rings | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Mercury | Terrestrial | 0.33 | 4879 | 5429 | 3.7 | 4222.6 | 57.9 | 88.0 | 167 | 0 | false |
| Venus | Terrestrial | 4.87 | 12104 | 5243 | 8.9 | 2802.0 | 108.2 | 224.7 | 464 | 0 | false |
| Earth | Terrestrial | 5.97 | 12756 | 5514 | 9.8 | 24.0 | 149.6 | 365.2 | 15 | 1 | false |
| Mars | Terrestrial | 0.642 | 6792 | 3934 | 3.7 | 24.7 | 228.0 | 687.0 | -65 | 2 | false |
| Jupiter | Gas giant | 1898.0 | 142984 | 1326 | 23.1 | 9.9 | 778.5 | 4331.0 | -110 | 95 | true |
| Saturn | Gas giant | 568.0 | 120536 | 687 | 9.0 | 10.7 | 1432.0 | 10747.0 | -140 | 146 | true |
| Uranus | Ice giant | 86.8 | 51118 | 1270 | 8.7 | 17.2 | 2867.0 | 30589.0 | -195 | 28 | true |
| Neptune | Ice giant | 102.0 | 49528 | 1638 | 11.0 | 16.1 | 4515.0 | 59800.0 | -200 | 16 | true |
How it worked
As for 0.1, a thread ported the pages while another built 0.2, and every finding went from one to the other as it was found. Four things were new.
- R first. gt's articles are written in R, so the book's tabs could say which side is the
original. Running them showed one thing about gt itself: a summary function named in a formula
(
~ f(.)) is found only in R's global environment, where knitr runs. The book's runner now runs there too. - The release waited for the book. Pietro decided that the 0.2 tag waits for the gt articles and their fixes. A finding in the last chapter could still change 0.2.
- The open findings were built too. This post first ended with three findings still open; reading it, Pietro asked for all three, and they went into 0.2 the same day.
- A second round, before the tag. The second round's findings were first written as gaps for a later release. Pietro read them and asked for them in 0.2: the book is updated before a release so that what it finds goes in. In one day 29 were built, each with its spec, a test and the chapter that needed it rewritten without its workaround; three stay open by his choice, and the list of gaps says why.
- The book is a test. Every change to tabelline rebuilds every chapter, so lists and records, the dot for rows and the blocks of pairs reached every page as soon as they were built, and a chapter that broke showed up in the pull request that broke it.
What the book will port next is in its plan.