Closed mbjohnsonmn closed 2 years ago
I found this is the code in gt_theme_guardian() that is producing the error:
tab_style(
style = cell_borders(
sides = "top", color = "white", weight = px(0)
),
locations = cells_body(rows = 1)
)
Since weight is set to px(0) I am not sure what this is for, but in any case was able to eliminate the error by commenting this out in a local copy. I am new to git and github so haven't worked out pull requests, yet, but I am working on it. ;-}
Howdy, thanks for the report!
I'm slightly confused, are you intending to create tables with no data in them?
In short, the px(0)
is necessary to remove the border formatting between the cell_label and the first row of data. While I could in theory add additional logic to "protect" against empty tables, I'm not following why you want a table without any rows/data?
Other themes don't have that specific set of code as they aren't changing the border between the label/cell body.
Hello Thomas,
Thanks for your work on this great package. Very helpful! I've also benefited greatly from the webinars you've created and shared on YouTube. Great work!
My app offers users various contrastive views or dashboards of a common data set. So it's important to present an empty table since that result is significant in this context.
As you say, I could build in some logic that catches the error and displays something other than the table.
Thanks again!
Morris
On Tue, Mar 29, 2022 at 9:46 AM Thomas Mock @.***> wrote:
Howdy, thanks for the report!
I'm slightly confused, are you intending to create tables with no data in them?
In short, the px(0) is necessary to remove the border formatting between the cell_label and the first row of data. While I could in theory add additional logic to "protect" against empty tables, I'm not following why you want a table without any rows/data?
Other themes don't have that specific set of code as they aren't changing the border between the label/cell body.
— Reply to this email directly, view it on GitHub https://github.com/jthomasmock/gtExtras/issues/41#issuecomment-1081963775, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC44IJ5VE6QMXDCD26JQWYLVCMJU3ANCNFSM5RLCP6CA . You are receiving this because you authored the thread.Message ID: @.***>
-- Morris Johnson *Global Partnerships *Strategic Innovations Consultant Wycliffe Bible Translators USA Arden Hills, MN 55112 LinkedIn https://www.linkedin.com/company/wycliffe-bible-translators/?viewAsMember=true wycliffe.org https://www2.wycliffe.org/e/26032/2019-03-19/7xsk6t/943822178?h=ASRPOP5WW4rQPDXrRiIleaqu8S-w6MG5ZzQlgnhdu2s
C: +1 651 324 5243
Thanks for the note! I've updated gt_theme_guardian()
to allow for zero-length tables.
In latest version on GH, see:
library(gt)
library(gtExtras)
head(mtcars) %>%
dplyr::filter(vs == 2) %>%
gt() %>%
gt_theme_guardian() %>%
gtsave("test.png")
Created on 2022-03-29 by the reprex package (v2.0.1)
Here is the reprex, from the documented example:
library(gt) themed_tab <- head(mtcars) %>% filter(vs == 2) %>% gt() %>% gt_theme_guardian() Error: The following row indices do not exist in the data: 1
gt_theme_nytimes and others do not produce this error.