From 99ea5347f7668661e9f5d66c335cc1c4c1361d22 Mon Sep 17 00:00:00 2001 From: olivroy Date: Fri, 14 Jun 2024 13:13:42 -0400 Subject: [PATCH] Add support for `gt(mtcars, rownames_to_stub = TRUE) |> opt_interactive()` --- NEWS.md | 2 ++ R/render_as_i_html.R | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 31c3001639..78daeb1578 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # gt (development version) +* `opt_interactive()` now shows row names if `rownames_to_stub = TRUE` (@olivroy, #1702). + * `data_color()` throws a more informative error message if `rows` didn't resolve to anything (@olivroy, #1659). * PDF output now allows the font size of a table to be set using the table.font.size parameter in the tab_options function (#1472). The font sizes of individual table cells (including those in the body, stubs, column headings, etc.) can be set using tab_style function. Several other options specified in tab_style are now reflected in PDF output. diff --git a/R/render_as_i_html.R b/R/render_as_i_html.R index 88756a8a23..9d9bbd1700 100644 --- a/R/render_as_i_html.R +++ b/R/render_as_i_html.R @@ -183,6 +183,8 @@ render_as_ihtml <- function(data, id) { column_labels_border_bottom_width <- opt_val(data = data, option = "column_labels_border_bottom_width") column_labels_border_bottom_color <- opt_val(data = data, option = "column_labels_border_bottom_color") + rownames_to_stub <- stub_rownames_has_column(data) + emoji_symbol_fonts <- c( "Apple Color Emoji", "Segoe UI Emoji", @@ -452,7 +454,7 @@ render_as_ihtml <- function(data, id) { data = data_tbl, columns = col_defs, columnGroups = colgroups_def, - rownames = NULL, + rownames = rownames_to_stub, groupBy = NULL, sortable = use_sorting, resizable = use_resizers,