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.
The purpose of typstable is to produce publication ready tables for Quarto documents targeting the Typst format. Typst is a modern, open-source, markup-based typesetting system that provides an alternative to LaTeX for rendering PDF documents. In this article I show how to use the typstable package.
Create a basic table with tt().
library(typstable)
sans_font <- '#set text(font: "Arial")'
tbl <- tt(mtcars[1:5, 1:3], preamble = sans_font)
tblFormat specific parts of the table with tt_column(),
tt_row(), and tt_cell(). Columns can be
targeted using tidyselect syntax.
tbl <- tt(mtcars[1:5, 1:3], preamble = sans_font) |>
tt_column(2:4, align = "center") |>
tt_row(3, fill = "yellow") |>
tt_cell(2, 2, bold = TRUE, rotate = 45, fill = "lightgrey")
tblUse tt_style() to customize the table appearance.
tbl <- tt(mtcars[1:5, 1:3],
col_names = c("", "Miles/Gallon", "Cylinders", "Displacement"),
preamble = sans_font) |>
tt_style(
striped = TRUE,
inset = "4pt"
)
tblControl relative column widths with tt_widths().
tbl <- tt(mtcars[1:5, 1:3], preamble = sans_font) |>
tt_style(stroke = TRUE) |>
tt_widths(.rownames=8,mpg=1,cyl=1,disp=1)Add spanning headers with tt_header_above():
tbl <- tt(mtcars[1:6, c("mpg", "qsec", "cyl", "disp", "hp", "wt")], preamble = sans_font) |>
tt_header_above(c(" " = 1, "Performance" = 2, "Characteristics" = 4), gap='5pt') |>
tt_column(1, width = "25%")
tblGroup rows with tt_pack_rows(). Sort the data by a
grouping variable, then use table() to compute group sizes
for the index parameter.
cars <- mtcars[order(mtcars$cyl), c("mpg", "disp", "hp", "wt", "cyl")]
cars <- do.call(dplyr::bind_rows, lapply(split(cars, cars$cyl), head, 3))
groups <- table(cars$cyl)
groups <- setNames(as.integer(groups), paste(names(groups), "Cylinders"))
tbl <- tt(cars, cols = c(.rownames, mpg, disp, hp, wt), preamble = sans_font) |>
tt_pack_rows(index = groups) |>
tt_column(1, width = "30%")
tblThese 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.