-
-
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.
- Loading branch information
Showing
10 changed files
with
107 additions
and
1 deletion.
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
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,24 @@ | ||
#' ARD Total N | ||
#' | ||
#' Returns the total N for the data frame. | ||
#' The placeholder variable name returned in the object is `"..ard_total_n.."` | ||
#' | ||
#' @inheritParams ard_dichotomous | ||
#' | ||
#' @return an ARD data frame of class 'card' | ||
#' @export | ||
#' | ||
#' @examples | ||
#' ard_total_n(ADSL) | ||
ard_total_n <- function(data) { | ||
# process inputs ------------------------------------------------------------- | ||
set_cli_abort_call() | ||
check_data_frame(data) | ||
|
||
# calculate total N ---------------------------------------------------------- | ||
data |> | ||
dplyr::mutate(..ard_total_n.. = TRUE) |> | ||
ard_dichotomous(variables = "..ard_total_n..", statistic = list(..ard_total_n.. = "N")) |> | ||
dplyr::mutate(context = "total_n") |> | ||
dplyr::select(-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
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,16 @@ | ||
# ard_total_n() works | ||
|
||
Code | ||
as.data.frame(ard_total_n(ADSL)) | ||
Output | ||
variable context stat_name stat_label stat fmt_fn warning error | ||
1 ..ard_total_n.. total_n N N 254 0 NULL NULL | ||
|
||
--- | ||
|
||
Code | ||
ard_total_n(letters) | ||
Condition | ||
Error in `ard_total_n()`: | ||
! The `data` argument must be class <data.frame>, not a character vector. | ||
|
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,11 @@ | ||
test_that("ard_total_n() works", { | ||
expect_snapshot( | ||
ard_total_n(ADSL) |> | ||
as.data.frame() | ||
) | ||
|
||
expect_snapshot( | ||
error = TRUE, | ||
ard_total_n(letters) | ||
) | ||
}) |