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

Restore functionality in inline_text.tbl_summary(column) #1885

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# gtsummary (development version)

* Restore functionality of `inline_text.tbl_summary(column)` argument to specify a by level when the by variable is a factor: a regression introduced in v2.0.0. (#1883)

* Correct the order of the columns when the `tbl_summary(by)` variables has ten or more levels: a regression introduced in v2.0.0. (#1877)

# gtsummary 2.0.0
Expand Down
2 changes: 1 addition & 1 deletion R/inline_text.tbl_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ inline_text.tbl_summary <- function(x,
dplyr::filter(.data$group1 %in% .env$x$inputs$by) |>
dplyr::select("gts_column", "group1_level") |>
unique() |>
dplyr::mutate(group1_level = unlist(.data$group1_level)) |>
dplyr::mutate(group1_level = unlist(.data$group1_level) |> as.character()) |>
deframe() |>
as.list()

Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-inline_text.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ test_that("inline_text.tbl_summary", {
inline_text(variable = grade, level = "I", column = "stat_1"),
"35 (36%)"
)

# ensure inline_text(column) argument works with factor levels
expect_equal(
trial |>
dplyr::mutate(trt = factor(trt)) |>
tbl_summary(by = trt, include = age) |>
inline_text(variable = "age", column = "Drug A", pattern = "{median}"),
"46"
)
})


Expand Down