gt
gt copied to clipboard
First look at faster interactive fmt_
Summary
First trivial attempt at removing the burden of multiple render_formats
calls for interactive tables.
I've tested this against some local test tables, and I've run the testthat tests - all looks OK... but I'm not sure if this change actually makes sense. I'm really unsure about the partial table build (e.g. no footnotes) that occur inside extract_cells
- if this is needed then it might be better to split extract_cells
into two functions?
Performance
Impact of this PR on:
# for local: devtools::load_all("../../play/gt")
library(gt)
library(tidyverse)
library(tictoc)
demo_length <- 10000
my_table <-
tibble(
Name = # generate random names
stringi::stri_rand_strings(demo_length, 10),
Population = round(runif(demo_length, 100000000, 1000000000)),
Score = runif(demo_length, 0, 1)
)
profvis::profvis({
html1 <- my_table |>
gt() |>
fmt_number(columns = "Population") |>
fmt_percent(columns = "Score") |>
opt_interactive() |>
gt:::as.tags.gt_tbl()
})
is:
Before PR | After PR |
---|---|
Related GitHub Issues and PRs
- Ref: #1528
Checklist
- [x] I understand and agree to the Code of Conduct.
- [ ] I have listed any major changes in the NEWS.
- [ ] I have added
testthat
unit tests totests/testthat
for any new functionality.