Learn R Programming

tinytable (version 0.14.0)

print.tinytable: 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 tinytable
print(x, output = get_option("tinytable_print_output", default = NULL), ...)

Value

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

Arguments

x

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

output

format in which a Tiny Table is printed: NULL or one of "latex", "markdown", "html", "typst", "dataframe", "tabulator". If NULL, the output is chosen based on these rules:

  • 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")