Search code examples
rpackagequartotinytable

R package [tinytable] adjust in-table image size


I am very excited about the features of the R package tinytable but I did not find a solution yet to adjust the image size if rendering my quarto document to word.

The problem can e.g. be reproduced if one uses the adjusted tutorial code below for a table with a histogram column in a quarto document. This results in the histogram pictures being by far too large in word. One solution would seem to adjust the size of the histogram images that are saved in the assets folder, but I did not find such an option.

library(tinytable)
options(tinytable_tt_digits = 3)

plot_data <- list(mtcars$mpg, mtcars$hp, mtcars$qsec)

dat <- data.frame(
  Variables = c("mpg", "hp", "qsec"), 
  Histogram = "",
  Density = "",
  Bar = "",
  Line = ""
)

tt(dat) |>
  plot_tt(j = 2, fun = "histogram", data = plot_data, height = 0.2) |>
  style_tt(j = 2:5, align = "l")

Word image:
word image link


Solution

  • In the latest development version of tinytable, you can control the size of images using the height argument of the plot_tt() function. The default size is also more sensible.

    You can install the latest version from github:

    library(remotes)
    install_github("vincentarelbundock/tinytable")
    

    Restart your R session completely. Then, try again.