Home > Software design >  gtExtras winloss table in loop rendering with partially raw, partially rendered HTML
gtExtras winloss table in loop rendering with partially raw, partially rendered HTML

Time:01-10

I am trying to print gtExtras::gt_plt_winloss tables in a for loop in a paged HTML RMarkdown document. Outside of a loop, the tables are rendering as expected. Inside of a loop, the table preview is as expected in the console but prints to PDF partially in raw and partially in rendered HTML. I would appreciate any help figuring out why the rendering is going wrong in the loop!

---
title: example
output: 
  pagedown::html_paged:
    toc: true
    toc_depth: 1
    self_contained: true
    number_sections: false
knit: pagedown::chrome_print
paged-footnotes: true
---
set.seed(37)
data_in <- dplyr::tibble(
  grp = rep(c("A", "B", "C"), each = 10),
  wins = sample(c(0,1,.5), size = 30, prob = c(0.45, 0.45, 0.1), replace = TRUE)
) %>%
  dplyr::group_by(grp) %>%
  dplyr::summarize(wins=list(wins), .groups = "drop")

win_table <- data_in %>%
  gt() %>%
  gt_plt_winloss(wins)

Renders as expected in console and in PDF:

```{r, results = 'asis'}
win_table %>% 
  tab_header("no loop")
```

enter image description here

  • Related