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

Portuguese language updates #1099

Merged
merged 4 commits into from
Jan 9, 2022
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: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
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)

* 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)
Expand Down
15 changes: 5 additions & 10 deletions R/add_p.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 <-
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
Binary file modified data-raw/gtsummary_translated.xlsx
Binary file not shown.
43 changes: 43 additions & 0 deletions tests/testthat/test-add_p.tbl_cross.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

})