You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I generally using gt in combination with patchwork to output chart/table combos. The development of as_gtable gave me far more flexibility to craft the output (from the former roundtrip to .png. Thanks!!!). I have used table.width = pct(100) to ensure that that table output spans the width of the container, while using the cols_width to apportion individual columns.
Might there be another manner to achieve the objective of forcing the table to fit the output container while maintaining relative spacing across columns?
Seems as_gtable drops the table.width requirement (without as_gtable, table.width and cols_width both retained):
library(gt)
library(gtExtras)
library(tidyverse)
start_date<-"2010-06-07"end_date<-"2010-06-08"### no as_gtable#### table.width not assigned#### works as expectedsp_tab<-sp500 %>%
select(-c(volume, adj_close)) %>%
dplyr::filter(date>=start_date&date<=end_date) %>%
gt() %>%
cols_width(date~ pct(50))
gt_reprex_image(sp_tab)
#### table.width assigned#### works as expectedsp_tab<-sp500 %>%
select(-c(volume, adj_close)) %>%
dplyr::filter(date>=start_date&date<=end_date) %>%
gt() %>%
tab_options(table.width= pct(100)) %>%
cols_width(date~ pct(50))
gt_reprex_image(sp_tab)
### w/ as_gtable#### table.width not assigned#### works as expectedsp_tab<-sp500 %>%
select(-c(volume, adj_close)) %>%
dplyr::filter(date>=start_date&date<=end_date) %>%
gt() %>%
cols_width(date~ pct(50)) %>%
as_gtable(plot=TRUE)
#### table.width assigned#### does not work as expectedsp_tab<-sp500 %>%
select(-c(volume, adj_close)) %>%
dplyr::filter(date>=start_date&date<=end_date) %>%
gt() %>%
tab_options(table.width= pct(100)) %>%
cols_width(date~ pct(50)) %>%
as_gtable(plot=TRUE)
Looking back now at the homebrew table width calculations I wrote, it seems like I didn't anticipate percentage-width columns, just fixed-width columns.
I'd have to study https://www.w3.org/TR/CSS21/tables.html#auto-table-layout and try to mirror that with grid-units somehow.
Prework
Seems potentially related to #1907
Question
I generally using gt in combination with patchwork to output chart/table combos. The development of as_gtable gave me far more flexibility to craft the output (from the former roundtrip to .png. Thanks!!!). I have used table.width = pct(100) to ensure that that table output spans the width of the container, while using the cols_width to apportion individual columns.
Might there be another manner to achieve the objective of forcing the table to fit the output container while maintaining relative spacing across columns?
Seems as_gtable drops the table.width requirement (without as_gtable, table.width and cols_width both retained):
Created on 2024-11-14 with reprex v2.1.1
The text was updated successfully, but these errors were encountered: