diff --git a/DESCRIPTION b/DESCRIPTION index d1d204f083..2af6d19575 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: gtsummary Title: Presentation-Ready Data Summary and Analytic Result Tables -Version: 1.5.0.9026 +Version: 1.5.0.9027 Authors@R: c(person(given = "Daniel D.", family = "Sjoberg", diff --git a/NEWS.md b/NEWS.md index 2a4577b373..e9b4a8cc0f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # gtsummary (development version) +* Updates and additions to Portuguese language translations. (#1098) + * Added `add_p.tbl_cross(test.args=)` argument. (#1095) * The `tbl_strata(.combine_args=)` has been added that lets you control all arguments in the `tbl_merge()` or `tbl_stack()` that occurs in `tbl_strata()`. (#1090) diff --git a/R/add_p.R b/R/add_p.R index 8400851cf6..af20025eaf 100644 --- a/R/add_p.R +++ b/R/add_p.R @@ -446,19 +446,14 @@ add_p.tbl_cross <- function(x, test = NULL, pvalue_fun = NULL, include = -any_of("..total..")) ) %>% eval() - # replacing the input dataset with the original from the `tbl_cross()` call + # replacing the input data set with the original from the `tbl_cross()` call x$inputs$data <- x_copy$inputs$data - # updating footnote - test_name <- x$meta_data$stat_test_lbl %>% discard(is.na) - x <- - modify_table_styling( - x, - columns = "p.value", - footnote = test_name - ) - if (source_note == TRUE) { + test_name <- + x$meta_data$stat_test_lbl %>% + discard(is.na) %>% + translate_text() # report p-value as a source_note # hiding p-value from output x <- diff --git a/R/sysdata.rda b/R/sysdata.rda index bc23f5fbd9..5eabcc7cd1 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/data-raw/gtsummary_translated.xlsx b/data-raw/gtsummary_translated.xlsx index fbd14d7543..92fb801c7b 100644 Binary files a/data-raw/gtsummary_translated.xlsx and b/data-raw/gtsummary_translated.xlsx differ diff --git a/tests/testthat/test-add_p.tbl_cross.R b/tests/testthat/test-add_p.tbl_cross.R index 16b21ae0cb..67ea3156f8 100644 --- a/tests/testthat/test-add_p.tbl_cross.R +++ b/tests/testthat/test-add_p.tbl_cross.R @@ -33,4 +33,47 @@ test_that("add_p.tbl_cross", { tbl$meta_data$stat_test_lbl[1], "Pearson's Chi-squared test" ) + + + # oddly, the p-value is NA in this case, mcnemar.test() doesn't error + df <- + tibble::tibble( + before = trial$response, + after = rev(trial$response) + ) + + expect_error({ + theme_gtsummary_language("pt") + tbl_pt <- + df %>% + tbl_cross() %>% + add_p(test = "mcnemar.test.wide", test.args = list(correct = FALSE)) + reset_gtsummary_theme() + }, + NA + ) + expect_equal( + tbl_pt$table_styling$footnote %>% + dplyr::filter(column == "p.value") %>% + purrr::pluck("footnote", 1), + "Teste de McNemar" + ) + + expect_error({ + theme_gtsummary_language("pt") + tbl_pt <- + df %>% + tbl_cross() %>% + add_p(test = "mcnemar.test.wide", test.args = list(correct = FALSE), + source_note = TRUE) + reset_gtsummary_theme() + }, + NA + ) + expect_equal( + tbl_pt$table_styling$source_note, + "Teste de McNemar, ", + ignore_attr = TRUE + ) + })