README.md

What?

tinytable is a small but powerful R package to draw beautiful tables in a variety of formats: HTML, LaTeX, Word, PDF, PNG, Markdown, and Typst. The user interface is minimalist and easy to learn, while giving users access to powerful frameworks to create endlessly customizable tables.

https://vincentarelbundock.github.io/tinytable/

Why?

There are already many excellent table-drawing packages in the R ecosystem. Why release a new one? As the maintainer of modelsummary, I needed a table-drawing package which was:

To achieve these goals, the design philosophy of tinytable rests on three pillars:

  1. Data is separate from style. The code that this package creates keeps the content of a table separate from the style sheet that applies to its cells. This is in contrast to other R packages that modify the actual text in each cell to style it. Keeping data and style separate allows tinytable to create human-readable files which are easy to edit, debug, and extend. It also enables developers to keep a simpler code base, with minimal use of messy regular expressions.

  2. Flexibility. Users’ needs are extremely varied, and a table-drawing package must be flexible enough to accomodate different ideas. To achieve this, tinytable builds on battle-tested and versatile frameworks like Bootstrap for HTML and tabularray for LaTeX.

  3. Lightweight is the right weight. Some of the most popular table-drawing packages in the R ecosystem are very heavy: A single library() call can sometimes load upwards of 65 R packages. In contrast, tinytable imports zero 3rd party R package by default.

Installation

tinytable is a relatively new package with rapid development. If you want to benefit from the latest features—showcased on the package website—you should install from R-Universe:

install.packages("tinytable", repos = "https://vincentarelbundock.r-universe.dev")

Alternatively, you can install it from CRAN:

install.packages("tinytable")

Restart R completely for the installation to take effect.

First steps

The best feature of tinytable is its simplicity. To draw a table, simply call the tt() function with your data frame as the first argument:

library(tinytable)

x <- mtcars[1:5, 1:5]

tt(x)

More complex tables can be created by calling arguments and chaining functions together. In the next example, we add a caption, footnote, colors, styles, and spanning column headers: wzxhzdk:3

## Tutorial The `tinytable` 0.5.0 tutorial will take you much further. It is available in two formats: - [Tutorial (PDF)](https://vincentarelbundock.github.io/tinytable/vignettes/tinytable_tutorial.pdf) - Tutorial (HTML): - [Tiny tables](https://vincentarelbundock.github.io/tinytable/vignettes/tinytable.html) - [Format](https://vincentarelbundock.github.io/tinytable/vignettes/format.html) - [Style](https://vincentarelbundock.github.io/tinytable/vignettes/style.html) - [Group labels](https://vincentarelbundock.github.io/tinytable/vignettes/group.html) - [Plots and images](https://vincentarelbundock.github.io/tinytable/vignettes/plot.html) - [Themes](https://vincentarelbundock.github.io/tinytable/vignettes/theme.html) - [Customization](https://vincentarelbundock.github.io/tinytable/vignettes/custom.html) - [FAQ](https://vincentarelbundock.github.io/tinytable/vignettes/faq.html) - [Alternatives](https://vincentarelbundock.github.io/tinytable/vignettes/alternatives.html) [1] Other formats like Markdown and Typst are also available, but less flexible. [2] Some extra packages can be imported to access specific functionality, such as integration with Quarto, inserting `ggplot2` objects as inline plots, and saving tables to PNG images or PDF documents.



Try the tinytable package in your browser

Any scripts or data that you put into this service are public.

tinytable documentation built on Oct. 5, 2024, 5:06 p.m.