Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with wrap_table() when using a gt table with footnotes coming from gtsummary #398

Open
ABohynDOE opened this issue Sep 26, 2024 · 0 comments

Comments

@ABohynDOE
Copy link

I tried to follow the examples presented in the release notes of patchwork 1.3.0 on the tidyverse blog, however I get an error when using a gt table coming from gtsummary instead of a gt table built from a data frame.

library(patchwork)
library(ggplot2)
library(gtsummary)

p1 <- ggplot(airquality) +
  geom_line(aes(x = Day, y = Temp, colour = month.name[Month])) +
  labs(colour = "Month")

fit <- lm(Temp ~ Day + Month, data = airquality)
tbl_fit <- tbl_regression(fit) |> as_gt()

p1 + wrap_table(tbl_fit, space = "free_y")
#> Error in apply_footnotes_method[[context]](boxh$column_label[boxh$var == : attempt to apply non-function

I strongly suspect that the error comes from the processing of footnotes because when the footnote is removed, there is no error anymore.

library(patchwork)
library(ggplot2)
library(gtsummary)

p1 <- ggplot(airquality) +
  geom_line(aes(x = Day, y = Temp, colour = month.name[Month])) +
  labs(colour = "Month")

fit <- lm(Temp ~ Day + Month, data = airquality)
tbl_fit <- tbl_regression(fit) |> 
  modify_footnote(everything() ~ NA, abbreviation = TRUE) |>
  as_gt()
  

p1 + wrap_table(tbl_fit, space = "free_y")

Created on 2024-09-26 with reprex v2.1.0

@ABohynDOE ABohynDOE changed the title Problem with wrap_table() when using a gt table coming from gtsummary Problem with wrap_table() when using a gt table with footnotes coming from gtsummary Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant