Saving table with gtsave() to .RTF file yields different table output? R

Viewed 249

I am using the gt package to make a table ad saving it as an .RTF. I'm using the function gt::gtsave() but the table saved looks very different from what is in my viewer or outputs to HTML.

Lin: to documentation I am using https://gt.rstudio.com/reference/gtsave.html

Here is the table I am making

library(gt)
library(tidyverse)
library(glue)

# Define the start and end dates for the data range
start_date <- "2010-06-07"
end_date <- "2010-06-14"

# Create a gt table based on preprocessed
# `sp500` table data
tab <- sp500 %>%
  filter(date >= start_date & date <= end_date) %>%
  select(-adj_close) %>%
  gt() %>%
  tab_header(
    title = "S&P 500",
    subtitle = glue("{start_date} to {end_date}")
  ) %>%
  fmt_date(
    columns = date,
    date_style = 3
  ) %>%
  fmt_currency(
    columns = c(open, high, low, close),
    currency = "USD"
  ) %>%
  fmt_number(
    columns = volume,
    suffixing = TRUE
  )

And here is it appears in my viewer or when using gtsave(tab,"tab.html")

enter image description here

But when I do

gtsave(tab,"tab.rtf")

This is the output: As you can see the table has cell borders on the left and right side and the spacing is not the same. Any idea why this is? Is it possible to export .rtf and keep the table the exact same as the viewer/html? enter image description here

0 Answers
Related