print.tinytable: Print, display, or convert a tinytable object

View source: R/print.R

print.tinytableR Documentation

Print, display, or convert a tinytable object

Description

This function is called automatically by R whenever a tinytable object is anprinted to the console or in an HTML viewer pane.

Usage

## S3 method for class 'tinytable'
print(x, output = get_option("tinytable_print_output", default = NULL), ...)

Arguments

x

A data frame, data table, or tibble to be rendered as a table.

output

Format in which a Tiny Table is printed. One of:

  • NULL: automatically chosen based on context (see below).

  • "html": HTML table. In interactive mode, displayed in the viewer pane.

  • "latex": LaTeX table using tabularray.

  • "markdown": plain text markdown table.

  • "typst": Typst table.

  • "dataframe": formatted data frame.

  • "tabulator": interactive HTML table using Tabulator.js.

  • "knitr": PNG screenshot via webshot2, returned through knitr::include_graphics(). Useful for embedding styled tables in Rmarkdown or Quarto documents. Requires the webshot2 package.

  • "raster": PNG screenshot via webshot2, drawn on the graphics device via grid::grid.raster(). Useful for pkgdown ⁠@examples⁠ and README files, where the plot is captured as an image. Requires the webshot2 and png packages. For README.Rmd files rendered with rmarkdown::render(), set knitr::opts_chunk$set(fig.path = "man/figures/README-") in a setup chunk so that pkgdown copies the images correctly.

When output is NULL, the format is chosen automatically:

  • When called from a script in non-interactive mode, the default is "markdown" (interactive() == FALSE).

  • When called interactively in RStudio, the default is to display an HTML table in the viewer pane.

  • When called interactively in another development environment, the default is "markdown".

  • The default print output can be changed for an entire R session by calling: options(tinytable_print_output = "html")

  • The default print output can be changed for a single tinytable object by modifying the output S4 slot.

...

Other arguments are ignored.

Details

When printing to HTML in interactive() mode, a temporary file is created and viewer() is called to preview the file with the local browser (ex: Firefox or Chrome). The temporary file is then automatically cleaned up. On some operating systems, like some Linux distributions, browser do not have read access to the ⁠/tmp/⁠ directory. In such cases, users can specify a custom location to store temporary HTML files. Note that this prevents tinytable from automatically cleaning up temporary files automatically.

options(tinytable_tempdir = "/home/username/temp_directory")

Value

launch a browser window or cat() the table to console.


tinytable documentation built on June 27, 2026, 1:06 a.m.