'Trouble reading HTML table saved with gtsave

I saved a table created by gt in HTML using gtsave. I'm having trouble loading and displaying this small HTML table in Shiny

The HTML table is at: https://filedropper.com/d/s/CyvqjLggB4Q0IkJ60BQsZkIwy3BVPm

The error I get is:

Warning: Error in FUN: argument is not a character vector

R Script

library("shiny")
library("tidyverse")

# Get HTML table from here (11KB) https://filedropper.com/d/s/CyvqjLggB4Q0IkJ60BQsZkIwy3BVPm
tbl <- read_html(x = "<path to 001_ins_tbl.html>")


ui <- fluidPage(
  uiOutput(outputId = "ins_table")
)

server <- function(input, output, session) {
  output$ins_table <- renderUI({
    HTML(tbl)
  })

}

shinyApp(ui, server)


Solution 1:[1]

The solution I used was to use convert the HTML page to an HTML fragment using as_raw_html(). In my case, this introduced an unwanted extra blank line in each cell which was removed by removing the <p> and </p> tags.

perk_html_tbl <- perk_html_tbl |>
      as_raw_html() |> 
      {function(x){gsub("<p>", "", x=x)}}() |> 
      {function(x){gsub("</p>", "", x=x)}}()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ixodid