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 viawebshot2, returned throughknitr::include_graphics(). Useful for embedding styled tables in Rmarkdown or Quarto documents. Requires thewebshot2package."raster": PNG screenshot viawebshot2, drawn on the graphics device viagrid::grid.raster(). Useful for pkgdown@examplesand README files, where the plot is captured as an image. Requires thewebshot2andpngpackages. For README.Rmd files rendered withrmarkdown::render(), setknitr::opts_chunk$set(fig.path = "man/figures/README-")in a setup chunk so that pkgdown copies the images correctly.
When
outputisNULL, 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
tinytableobject by modifying theoutputS4 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")