bstfun
bstfun copied to clipboard
Error with add_continuous_stat function
I've been experiencing difficulties for the past 2 days using the "add_continous_stat" function (which was working perfectly 6 months ago with the same code)
Here's the code from documentation for easier reproductability
library(dplyr)
set.seed(1123)
likert_lvls <- c("Never", "Sometimes", "Often", "Always")
df <- tibble::tibble( Q1 = sample(likert_lvls, size = 100, replace = TRUE), Q2 = sample(likert_lvls, size = 100, replace = TRUE) ) %>% mutate(across(c(Q1, Q2), ~factor(., levels = likert_lvls)))
tbl_likert_ex1 <- tbl_likert(df) %>% add_n() %>% add_continuous_stat(statistic = "{mean}") %>% add_continuous_stat(statistic = "{sd}")
And here's the error message :
Error in
purrr::map()
:
ℹ In index: 1. Caused by error in
scope_tidy()
: ! The.$x
data frame does not have the required "variable" column.
Backtrace: ▆
- ├─... %>% add_continuous_stat(statistic = "{sd}")
- ├─bstfun::add_continuous_stat(., statistic = "{sd}")
- ├─bstfun::add_continuous_stat(., statistic = "{mean}")
- ├─gtsummary::add_n(.)
- ├─bstfun::tbl_likert(df)
- │ └─... %>% structure(class = c("tbl_likert", "gtsummary"))
- ├─base::structure(., class = c("tbl_likert", "gtsummary"))
- ├─purrr::list_modify(., inputs = func_inputs)
- │ └─purrr:::check_list(.x)
- ├─gtsummary::tbl_butcher(.)
- ├─gtsummary::tbl_stack(., quiet = TRUE)
- ├─purrr::map(...)
- │ └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
- │ ├─purrr:::with_indexed_errors(...)
- │ │ └─base::withCallingHandlers(...)
- │ ├─purrr:::call_with_cleanup(...)
- │ └─bstfun (local) .f(.x[[i]], ...)
- │ ├─... %>% ...
- │ └─gtsummary::tbl_summary(...)
- │ └─... %>% ...
- ├─gtsummary::modify_table_body(...)
- │ └─gtsummary:::.assert_class(x, "gtsummary")
- ├─gtsummary::modify_header(., gtsummary::all_stat_cols() ~ "{level}")
- └─gtsummary::modify_header(...)
- └─gtsummary:::.combine_update_and_dots(x, update, ...)
└─broom.helpers::.formula_list_to_named_list(...)
└─broom.helpers:::.single_formula_to_list(...)
└─broom.helpers::.select_to_varnames(...)
└─broom.helpers::scope_tidy(var_info, data)