-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 187_ard_poisson_test@main
- Loading branch information
Showing
12 changed files
with
156 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: cardx | ||
Title: Extra Analysis Results Data Utilities | ||
Version: 0.2.0.9005 | ||
Version: 0.2.0.9006 | ||
Authors@R: c( | ||
person("Daniel", "Sjoberg", , "[email protected]", role = c("aut", "cre")), | ||
person("Abinaya", "Yogasekaram", , "[email protected]", role = "aut"), | ||
|
@@ -19,7 +19,7 @@ BugReports: https://github.com/insightsengineering/cardx/issues | |
Depends: | ||
R (>= 4.1) | ||
Imports: | ||
cards (>= 0.2.0), | ||
cards (>= 0.2.1.9003), | ||
cli (>= 3.6.1), | ||
dplyr (>= 1.1.2), | ||
glue (>= 1.6.2), | ||
|
@@ -30,7 +30,7 @@ Suggests: | |
broom (>= 1.0.5), | ||
broom.helpers (>= 1.15.0), | ||
broom.mixed (>= 0.2.9), | ||
car (>= 3.0-11), | ||
car (>= 3.1-2), | ||
effectsize (>= 0.8.8), | ||
emmeans (>= 1.7.3), | ||
geepack (>= 1.3.2), | ||
|
@@ -43,6 +43,8 @@ Suggests: | |
survival (>= 3.6-4), | ||
testthat (>= 3.2.0), | ||
withr (>= 2.5.0) | ||
Remotes: | ||
insightsengineering/cards | ||
Config/Needs/website: insightsengineering/nesttemplate | ||
Config/testthat/edition: 3 | ||
Config/testthat/parallel: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#' ARD Total N | ||
#' | ||
#' Returns the total N for a survey object. | ||
#' The placeholder variable name returned in the object is `"..ard_total_n.."` | ||
#' | ||
#' @inheritParams ard_dichotomous.survey.design | ||
#' @inheritParams rlang::args_dots_empty | ||
#' | ||
#' @return an ARD data frame of class 'card' | ||
#' @export | ||
#' | ||
#' @examplesIf cardx:::is_pkg_installed("survey", reference_pkg = "cardx") | ||
#' svy_titanic <- survey::svydesign(~1, data = as.data.frame(Titanic), weights = ~Freq) | ||
#' | ||
#' ard_total_n(svy_titanic) | ||
ard_total_n.survey.design <- function(data, ...) { | ||
# process inputs ------------------------------------------------------------- | ||
set_cli_abort_call() | ||
check_dots_empty() | ||
|
||
# calculate total N ---------------------------------------------------------- | ||
data$variables <- | ||
data$variables |> | ||
dplyr::mutate(..ard_total_n.. = TRUE) | ||
|
||
data |> | ||
ard_dichotomous( | ||
variables = "..ard_total_n..", | ||
statistic = list(..ard_total_n.. = c("N", "N_unweighted")) | ||
) |> | ||
dplyr::mutate(context = "total_n") |> | ||
dplyr::select(-cards::all_ard_variables("levels")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# ard_total_n.survey.design() works | ||
|
||
Code | ||
ard_total_n(survey::svydesign(~1, data = as.data.frame(Titanic), weights = ~ | ||
Freq)) | ||
Message | ||
{cards} data frame: 2 x 8 | ||
Output | ||
variable context stat_name stat_label stat fmt_fn | ||
1 ..ard_total_n.. total_n N N 2201 <fn> | ||
2 ..ard_total_n.. total_n N_unweighted Unweight… 32 <fn> | ||
Message | ||
i 2 more variables: warning, error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
skip_if_not(is_pkg_installed("survey", reference_pkg = "cardx")) | ||
|
||
test_that("ard_total_n.survey.design() works", { | ||
expect_snapshot( | ||
survey::svydesign(~1, data = as.data.frame(Titanic), weights = ~Freq) |> | ||
ard_total_n() | ||
) | ||
}) | ||
|
||
test_that("ard_total_n.survey.design() follows ard structure", { | ||
expect_silent( | ||
survey::svydesign(~1, data = as.data.frame(Titanic), weights = ~Freq) |> | ||
ard_total_n() |> | ||
cards::check_ard_structure(method = FALSE) | ||
) | ||
}) |