Skip to content

Commit

Permalink
Merge branch 'main' into 911_summarize_vars_bug@main
Browse files Browse the repository at this point in the history
  • Loading branch information
edelarua authored May 17, 2023
2 parents 87ec1ed + ef3e5e5 commit 64e3089
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Added new "Analyze Functions" and "Summarize Functions" overview pages.
* Moved all KM plot documentation to the `g_km` function.
* Added `a_count_patients_sum_exposure` for new analyze function `analyze_patients_exposure_in_cols` and `summarize_patients_exposure_in_cols`.
* Added more informative error when the user selects an invalid method for unstratified analyses in `s_proportion_diff`.

### Miscellaneous
* Implemented the `lubridate` package for date variables in `tern` datasets.
Expand Down
9 changes: 9 additions & 0 deletions R/prop_diff.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ NULL
#' @return
#' * `s_proportion_diff()` returns a named list of elements `diff` and `diff_ci`.
#'
#' @note When performing an unstratified analysis, methods `"cmh"`, `"strat_newcombe"`, and `"strat_newcombecc"` are
#' not permitted.
#'
#' @examples
#' # Summary
#'
Expand Down Expand Up @@ -65,6 +68,12 @@ s_proportion_diff <- function(df,
),
weights_method = "cmh") {
method <- match.arg(method)
if (is.null(variables$strata) && checkmate::test_subset(method, c("cmh", "strat_newcombe", "strat_newcombecc"))) {
stop(paste(
"When performing an unstratified analysis, methods 'cmh', 'strat_newcombe', and 'strat_newcombecc' are not",
"permitted. Please choose a different method."
))
}
y <- list(diff = "", diff_ci = "")

if (!.in_ref_col) {
Expand Down
4 changes: 4 additions & 0 deletions man/prop_diff.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions tests/testthat/_snaps/summarize_coxreg.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
row_name formatted_cell indent_mod row_label
1 Label 1 340 0 Label 1

# summarize_coxreg adds the univariable Cox regression layer to rtables
# summarize_coxreg adds the univariate Cox regression layer to rtables

Code
res
Expand Down Expand Up @@ -97,7 +97,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Sex (F/M) 340 0.62 (0.42, 0.92) 0.0182

# summarize_coxreg works with interactions in univariable case
# summarize_coxreg works with interactions in univariate case

Code
res
Expand All @@ -118,7 +118,7 @@
F 0.67 (0.36, 1.22)
M 0.60 (0.36, 0.99)

# summarize_coxreg 'at' argument works in univariable case
# summarize_coxreg 'at' argument works in univariate case

Code
res
Expand Down Expand Up @@ -155,7 +155,7 @@
F 0.67 (0.36, 1.22) ---
M 0.60 (0.36, 0.99) ---

# summarize_coxreg works without treatment arm in univariable case
# summarize_coxreg works without treatment arm in univariate case

Code
res
Expand All @@ -170,7 +170,7 @@
Sex (F/M) (reference = F)
M 1.33 (0.97, 1.82) 0.1414

# summarize_coxreg works with numeric covariate without treatment arm in univariable case
# summarize_coxreg works with numeric covariate without treatment arm in univariate case

Code
res
Expand Down

0 comments on commit 64e3089

Please sign in to comment.