Skip to content

Commit

Permalink
Using glue_data(.x) instead of glue(.envir) (#1990)
Browse files Browse the repository at this point in the history
* Using glue_data(.x) instead of glue(.envir)

* Update DESCRIPTION

* Update NEWS.md
  • Loading branch information
ddsjoberg authored Sep 19, 2024
1 parent a93e56f commit d9b1952
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 147 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,4 @@ importFrom(dplyr,starts_with)
importFrom(dplyr,vars)
importFrom(dplyr,where)
importFrom(glue,glue)
importFrom(glue,glue_data)
12 changes: 6 additions & 6 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# gtsummary (development version)

* Headers in {gt} tables being exported to PDF do not support the `\n` line breaker. Previously, line breakers were stripped from the header in the `print.gtsummary()` S3 method. But this did not apply to users utilizing `as_gt()` to further customize their tables. As a result, the line breaking strip has been migrated to `as_gt()`. (#1960)

* Removed the `"tbl_summary-arg:statistic"` theme that was incorrectly added to `tbl_continuous()`.

* Made the `oneway.test()` available in `add_p.tbl_continuous()`. (#1970)

* Removed the deprecated `'aov'` test from the `tests.R` file listing available tests. (#1970)

* Added argument `tbl_ard_summary(overall)`. When `TRUE`, the ARD is parsed into primary ARD and the Overall ARD and we run `tbl_ard_summary() |> add_overall()`. (#1940)

* Added `add_stat_label.tbl_ard_summary()` method. (#1969)

* Headers in {gt} tables being exported to PDF do not support the `\n` line breaker. Previously, line breakers were stripped from the header in the `print.gtsummary()` S3 method. But this did not apply to users utilizing `as_gt()` to further customize their tables. As a result, the line breaking strip has been migrated to `as_gt()`. (#1960)

* Removed the `"tbl_summary-arg:statistic"` theme that was incorrectly added to `tbl_continuous()`.

* Removed the deprecated `'aov'` test from the `tests.R` file listing available tests. (#1970)

* Removed documentation for the `add_overall.tbl_ard_summary(digits)` argument, which was never meant to be a part of this function. (#1975)

# gtsummary 2.0.2
Expand Down
14 changes: 7 additions & 7 deletions R/add_stat_label.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ add_stat_label.tbl_summary <- function(x, location = c("row", "column"), label =
dplyr::mutate(
row_type = "missing",
stat_label =
glue::glue(
x$inputs$missing_stat,
.envir = list(N_obs = "N",
N_miss = "n",
N_nonmiss = "N - n",
p_miss = "p",
p_nonmiss = "1 - p")
glue::glue_data(
.x = list(N_obs = "N",
N_miss = "n",
N_nonmiss = "N - n",
p_miss = "p",
p_nonmiss = "1 - p"),
x$inputs$missing_stat
)
)
)
Expand Down
26 changes: 13 additions & 13 deletions R/brdg_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ pier_summary_categorical <- function(cards,
str_statistic_pre_glue,
function(str_to_glue) {
stat <-
glue::glue(
str_to_glue,
.envir =
glue::glue_data(
.x =
cards::get_ard_statistics(df_variable_level_stats, .column = "stat_fmt") |>
c(lst_variable_stats)
c(lst_variable_stats),
str_to_glue
) |>
as.character()
}
Expand Down Expand Up @@ -345,9 +345,9 @@ pier_summary_continuous2 <- function(cards,
statistic[[.y$variable[1]]],
function(str_to_glue) {
stat <-
glue::glue(
str_to_glue,
.envir = cards::get_ard_statistics(.x, .column = "stat_fmt")
glue::glue_data(
.x = cards::get_ard_statistics(.x, .column = "stat_fmt"),
str_to_glue
) |>
as.character()
}
Expand All @@ -358,9 +358,9 @@ pier_summary_continuous2 <- function(cards,
statistic[[.y$variable[1]]],
function(str_to_glue) {
label <-
glue::glue(
str_to_glue,
.envir = cards::get_ard_statistics(.x, .column = "stat_label")
glue::glue_data(
.x = cards::get_ard_statistics(.x, .column = "stat_label"),
str_to_glue
) |>
as.character()
}
Expand Down Expand Up @@ -453,9 +453,9 @@ pier_summary_continuous <- function(cards,
dplyr::mutate(
.data = .y,
stat =
glue::glue(
statistic[[.data$variable[1]]],
.envir = cards::get_ard_statistics(.x, .column = "stat_fmt")
glue::glue_data(
.x = cards::get_ard_statistics(.x, .column = "stat_fmt"),
statistic[[.data$variable[1]]]
) |>
as.character()
)
Expand Down
2 changes: 1 addition & 1 deletion R/gtsummary-package.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' @keywords internal
#' @import rlang
#' @importFrom dplyr across
#' @importFrom glue glue
#' @importFrom glue glue glue_data
"_PACKAGE"

## usethis namespace: start
Expand Down
8 changes: 4 additions & 4 deletions R/tbl_uvregression.R
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ is_quo_empty <- function(x) {
\(variable) {
formula_i <-
cards::eval_capture_conditions(
glue(
formula,
.envir = list(y = ifelse(is_empty(y), cardx::bt(variable), y),
x = ifelse(is_empty(x), cardx::bt(variable), x))
glue_data(
.x = list(y = ifelse(is_empty(y), cardx::bt(variable), y),
x = ifelse(is_empty(x), cardx::bt(variable), x)),
formula
) |>
stats::as.formula()
)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/tbl_continuous.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
Error in `tbl_continuous()`:
! Elements of the `label` argument must be strings.

# tbl_continuous(type,value)
# tbl_continuous(value)

Code
df <- as.data.frame(tbl_continuous(trial, variable = age, include = c(trt,
Expand Down Expand Up @@ -121,7 +121,7 @@
4 II 47 (34, 55) 49 (44, 58)
5 III 46 (38, 59) 50 (43, 58)

# tbl_continuous(type,value) messaging
# tbl_continuous(value) messaging

Code
tbl_continuous(trial, variable = age, include = c(trt, grade), value = trt ~
Expand Down
Loading

0 comments on commit d9b1952

Please sign in to comment.