Insert images and inline plots into tinytable objects
Insert images and inline plots into tinytable objects
The plot_tt() function allows for the insertion of images and inline plots into tinytable objects. This function can handle both local and web-based images.
plot_tt( x, i =NULL, j =NULL, fun =NULL, data =NULL, color ="black", xlim =NULL, height =1, asp =1/3, images =NULL, assets ="tinytable_assets",...)
Arguments
x: A tinytable object.
i: Integer vector, the row indices where images are to be inserted. If NULL, images will be inserted in all rows.
j: Integer vector, the column indices where images are to be inserted. If NULL, images will be inserted in all columns.
fun: String or function to generate inline plots.
String: "histogram", "density", "bar", "line"
Functions that return ggplot2 objects.
Functions that return another function which generates a base R plot, ex: function(x) {function() hist(x)}
See the tutorial on the tinytable website for more information.
data: a list of data frames or vectors to be used by the plotting functions in fun.
color: string Name of color to use for inline plots (passed to the col argument base graphics plots in R).
xlim: Numeric vector of length 2.
height: Numeric, the height of the images in the table in em units.
asp: Numeric, aspect ratio of the plots (height / width).
images: Character vector, the paths to the images to be inserted. Paths are relative to the main table file or Quarto (Rmarkdown) document.
assets: Path to the directory where generated assets are stored. This path is relative to the location where a table is saved.
...: Extra arguments are passed to the function in fun. Important: Custom plotting functions must always have ... as an argument.
Returns
A modified tinytable object with images or plots inserted.
Details
The plot_tt() can insert images and inline plots into tables.