Title: | Secular affirmations against data |
---|---|
Description: | What the package does (one paragraph). |
Authors: | Daniel D. Sjoberg [aut] , Travis Gerke [aut] , Shannon Pileggi [aut] , PCCTC, LLC [cph, cre] |
Maintainer: | "PCCTC, LLC" <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.0.9001 |
Built: | 2024-11-14 23:28:54 UTC |
Source: | https://github.com/pcctc/affirm |
A wrapper for affirm_true()
.
The condition
argument is process and passed to
affirm_true(condition = !condition)
affirm_false( data, label, condition, id = NA_integer_, priority = NA_integer_, data_frames = NA_character_, columns = NA_character_, report_listing = NULL, data_action = NULL, error = getOption("affirm.error", default = FALSE) )
affirm_false( data, label, condition, id = NA_integer_, priority = NA_integer_, data_frames = NA_character_, columns = NA_character_, report_listing = NULL, data_action = NULL, error = getOption("affirm.error", default = FALSE) )
data |
a data frame |
label |
a string used to describe the affirmation |
condition |
expression to check that evaluates to a logical vector, e.g. |
id , priority , data_frames , columns
|
Optional additional information that will be passed to affirmation report.
|
report_listing |
an expression selecting/filtering rows from |
data_action |
this expression is executed at the end of the function call when supplied.
|
error |
Logical indicating whether to throw an error when condition is not met. Default is |
data frame
Other Data Affirmations:
affirm_na()
,
affirm_no_dupes()
,
affirm_range()
,
affirm_true()
,
affirm_values()
affirm_init(replace = TRUE) dplyr::as_tibble(mtcars) |> affirm_false( label = "No. cylinders must be 4, 6, or 8", condition = !cyl %in% c(4, 6, 8) ) affirm_close()
affirm_init(replace = TRUE) dplyr::as_tibble(mtcars) |> affirm_false( label = "No. cylinders must be 4, 6, or 8", condition = !cyl %in% c(4, 6, 8) ) affirm_close()
Run this function to initialize a new affirmation report
affirm_init(replace = NA) affirm_close()
affirm_init(replace = NA) affirm_close()
replace |
logical indicating whether to replace/delete an existing or
in-progress affirmation report. Default is |
affirm_init() affirm_close()
affirm_init() affirm_close()
A wrapper for affirm_true()
.
Reports columns
that do not inherit class
, e.g.
dplyr::select(data, all_of(columns) && where(\(x) !inherits(x, class)))
A wrapper for affirm_true()
.
Reports columns
whose names end with ".x"
or ".y"
, indicating
a sloppy merge.
A wrapper for affirm_true()
.
The columns argument is used to construct the
affirm_true(condition = is.na(column))
argument.
affirm_class( data, label, columns, class, id = NA_integer_, priority = NA_integer_, data_frames = NA_character_, report_listing = NULL, data_action = NULL, error = getOption("affirm.error", default = FALSE) ) affirm_clean_join( data, label, id = NA_integer_, priority = NA_integer_, data_frames = NA_character_, report_listing = NULL, data_action = NULL, error = getOption("affirm.error", default = FALSE) ) affirm_na( data, label, column, id = NA_integer_, priority = NA_integer_, data_frames = NA_character_, report_listing = NULL, data_action = NULL, error = getOption("affirm.error", default = FALSE) ) affirm_not_na( data, label, column, id = NA_integer_, priority = NA_integer_, data_frames = NA_character_, report_listing = NULL, data_action = NULL, error = getOption("affirm.error", default = FALSE) )
affirm_class( data, label, columns, class, id = NA_integer_, priority = NA_integer_, data_frames = NA_character_, report_listing = NULL, data_action = NULL, error = getOption("affirm.error", default = FALSE) ) affirm_clean_join( data, label, id = NA_integer_, priority = NA_integer_, data_frames = NA_character_, report_listing = NULL, data_action = NULL, error = getOption("affirm.error", default = FALSE) ) affirm_na( data, label, column, id = NA_integer_, priority = NA_integer_, data_frames = NA_character_, report_listing = NULL, data_action = NULL, error = getOption("affirm.error", default = FALSE) ) affirm_not_na( data, label, column, id = NA_integer_, priority = NA_integer_, data_frames = NA_character_, report_listing = NULL, data_action = NULL, error = getOption("affirm.error", default = FALSE) )
data |
a data frame |
label |
a string used to describe the affirmation |
columns |
columns to check class |
class |
character class to affirm |
id , priority , data_frames
|
Optional additional information that will be passed to affirmation report.
|
report_listing |
an expression selecting/filtering rows from |
data_action |
this expression is executed at the end of the function call when supplied.
|
error |
Logical indicating whether to throw an error when condition is not met. Default is |
column |
column to check NA values against |
data frame
data frame
data frame
Other Data Affirmations:
affirm_false()
,
affirm_no_dupes()
,
affirm_range()
,
affirm_true()
,
affirm_values()
Other Data Affirmations:
affirm_false()
,
affirm_no_dupes()
,
affirm_range()
,
affirm_true()
,
affirm_values()
Other Data Affirmations:
affirm_false()
,
affirm_no_dupes()
,
affirm_range()
,
affirm_true()
,
affirm_values()
affirm_init(replace = TRUE) affirm_class( dplyr::as_tibble(iris), label = "all cols are numeric (but Species really isn't)", columns = everything(), class = "numeric" ) affirm_close() affirm_init(replace = TRUE) df <- dplyr::tibble(lgl = c(NA, TRUE, NA, FALSE, NA)) |> dplyr::mutate(id = dplyr::row_number()) affirm_clean_join( dplyr::full_join(df, df, by = "id"), label = "Checking for clean merge" ) affirm_close() affirm_init(replace = TRUE)
affirm_init(replace = TRUE) affirm_class( dplyr::as_tibble(iris), label = "all cols are numeric (but Species really isn't)", columns = everything(), class = "numeric" ) affirm_close() affirm_init(replace = TRUE) df <- dplyr::tibble(lgl = c(NA, TRUE, NA, FALSE, NA)) |> dplyr::mutate(id = dplyr::row_number()) affirm_clean_join( dplyr::full_join(df, df, by = "id"), label = "Checking for clean merge" ) affirm_close() affirm_init(replace = TRUE)
A wrapper for affirm_true()
.
The columns argument is used to construct the
affirm_true(condition = dplyr::select(., all_of(columns)) |> duplicated())
argument.
affirm_no_dupes( data, label, columns, id = NA_integer_, priority = NA_integer_, data_frames = NA_character_, report_listing = NULL, data_action = NULL, error = getOption("affirm.error", default = FALSE) )
affirm_no_dupes( data, label, columns, id = NA_integer_, priority = NA_integer_, data_frames = NA_character_, report_listing = NULL, data_action = NULL, error = getOption("affirm.error", default = FALSE) )
data |
a data frame |
label |
a string used to describe the affirmation |
columns |
columns to check duplicates among |
id , priority , data_frames
|
Optional additional information that will be passed to affirmation report.
|
report_listing |
an expression selecting/filtering rows from |
data_action |
this expression is executed at the end of the function call when supplied.
|
error |
Logical indicating whether to throw an error when condition is not met. Default is |
data frame
Other Data Affirmations:
affirm_false()
,
affirm_na()
,
affirm_range()
,
affirm_true()
,
affirm_values()
affirm_init(replace = TRUE) dplyr::as_tibble(mtcars) |> affirm_no_dupes( label = "No duplicates in the number of cylinders", columns = cyl ) affirm_close()
affirm_init(replace = TRUE) dplyr::as_tibble(mtcars) |> affirm_no_dupes( label = "No duplicates in the number of cylinders", columns = cyl ) affirm_close()
A wrapper for affirm_true()
.
The column, range, and boundaries arguments are used to construct the
affirm_true(condition = column >= range[1] & column <= range[2])
argument.
affirm_range( data, label, column, range, boundaries = c(TRUE, TRUE), id = NA_integer_, priority = NA_integer_, data_frames = NA_character_, report_listing = NULL, data_action = NULL, error = getOption("affirm.error", default = FALSE) )
affirm_range( data, label, column, range, boundaries = c(TRUE, TRUE), id = NA_integer_, priority = NA_integer_, data_frames = NA_character_, report_listing = NULL, data_action = NULL, error = getOption("affirm.error", default = FALSE) )
data |
a data frame |
label |
a string used to describe the affirmation |
column |
a single column to check values of |
range |
vector of length two indicating the upper and lower bounds of the range.
The class of the |
boundaries |
logical vector of length 2 indicating whether to include UB and LB in
the range check. Default is |
id , priority , data_frames
|
Optional additional information that will be passed to affirmation report.
|
report_listing |
an expression selecting/filtering rows from |
data_action |
this expression is executed at the end of the function call when supplied.
|
error |
Logical indicating whether to throw an error when condition is not met. Default is |
data frame
Other Data Affirmations:
affirm_false()
,
affirm_na()
,
affirm_no_dupes()
,
affirm_true()
,
affirm_values()
affirm_init(replace = TRUE) dplyr::as_tibble(mtcars) |> affirm_range( label = "MPG is >0 and <=30", column = mpg, range = c(0, 30), boundaries = c(FALSE, TRUE) ) affirm_close()
affirm_init(replace = TRUE) dplyr::as_tibble(mtcars) |> affirm_range( label = "MPG is >0 and <=30", column = mpg, range = c(0, 30), boundaries = c(FALSE, TRUE) ) affirm_close()
affirm_report_gt()
returns styled gt table summarizing results of affirmation session.
affirm_report_excel()
returns excel file with one sheet per affirmation (excluding those with no errors)
affirm_report_raw_data()
returns raw data used to generate summary in affirm_report_gt()
affirm_report_gt() affirm_report_excel( file, affirmation_name = "{data_frames}{id}", overwrite = TRUE ) affirm_report_raw_data()
affirm_report_gt() affirm_report_excel( file, affirmation_name = "{data_frames}{id}", overwrite = TRUE ) affirm_report_raw_data()
file |
A file path to save the xlsx file |
affirmation_name |
A string for affirmation names; the item name
in curly brackets is replaced with the item value (see glue::glue). Item names
accepted include: |
overwrite |
Overwrite existing file (Defaults to |
gt table
affirm_init(replace = TRUE) dplyr::as_tibble(mtcars) |> affirm_true( label = "No. cylinders must be 4, 6, or 8", condition = cyl %in% c(4, 6, 8) ) |> affirm_true( label = "MPG should be less than 33", condition = mpg < 33 ) gt_report <- affirm_report_gt() affirm_close()
affirm_init(replace = TRUE) dplyr::as_tibble(mtcars) |> affirm_true( label = "No. cylinders must be 4, 6, or 8", condition = cyl %in% c(4, 6, 8) ) |> affirm_true( label = "MPG should be less than 33", condition = mpg < 33 ) gt_report <- affirm_report_gt() affirm_close()
Use this function to affirm an expression is true.
affirm_true( data, label, condition, id = NA_integer_, priority = NA_integer_, data_frames = NA_character_, columns = NA_character_, report_listing = NULL, data_action = NULL, error = getOption("affirm.error", default = FALSE) )
affirm_true( data, label, condition, id = NA_integer_, priority = NA_integer_, data_frames = NA_character_, columns = NA_character_, report_listing = NULL, data_action = NULL, error = getOption("affirm.error", default = FALSE) )
data |
a data frame |
label |
a string used to describe the affirmation |
condition |
expression to check that evaluates to a logical vector, e.g. |
id , priority , data_frames , columns
|
Optional additional information that will be passed to affirmation report.
|
report_listing |
an expression selecting/filtering rows from |
data_action |
this expression is executed at the end of the function call when supplied.
|
error |
Logical indicating whether to throw an error when condition is not met. Default is |
When passing expressions to arguments report_listing=
and data_action=
,
there are a few things to keep in mind.
The expression passed in condition=
can be used, but note that it has
been captured as an expression inside the function. This means that to
use it, you'll need to use !!
(bang-bang) to pass it inside a function.
In addition to being able to use the condition=
expression, you can simplify
your code somewhat by referring to lgl_condition
, which is an evaluated logical
vector of the condition=
expression.
data frame
Other Data Affirmations:
affirm_false()
,
affirm_na()
,
affirm_no_dupes()
,
affirm_range()
,
affirm_values()
affirm_init(replace = TRUE) dplyr::as_tibble(mtcars) |> affirm_true( label = "No. cylinders must be 4, 6, or 8", condition = cyl %in% c(4, 6, 8) ) affirm_close()
affirm_init(replace = TRUE) dplyr::as_tibble(mtcars) |> affirm_true( label = "No. cylinders must be 4, 6, or 8", condition = cyl %in% c(4, 6, 8) ) affirm_close()
A wrapper for affirm_true()
.
The column and value arguments are used to construct the
affirm_true(condition = column %in% value)
argument.
affirm_values( data, label, column, values, id = NA_integer_, priority = NA_integer_, data_frames = NA_character_, report_listing = NULL, data_action = NULL, error = getOption("affirm.error", default = FALSE) )
affirm_values( data, label, column, values, id = NA_integer_, priority = NA_integer_, data_frames = NA_character_, report_listing = NULL, data_action = NULL, error = getOption("affirm.error", default = FALSE) )
data |
a data frame |
label |
a string used to describe the affirmation |
column |
a single column to check values of |
values |
vector of values the |
id , priority , data_frames
|
Optional additional information that will be passed to affirmation report.
|
report_listing |
an expression selecting/filtering rows from |
data_action |
this expression is executed at the end of the function call when supplied.
|
error |
Logical indicating whether to throw an error when condition is not met. Default is |
data frame
Other Data Affirmations:
affirm_false()
,
affirm_na()
,
affirm_no_dupes()
,
affirm_range()
,
affirm_true()
affirm_init(replace = TRUE) dplyr::as_tibble(mtcars) |> affirm_values( label = "No. cylinders must be 4, 6, or 8", column = cyl, values = c(4, 6, 8) ) affirm_close()
affirm_init(replace = TRUE) dplyr::as_tibble(mtcars) |> affirm_values( label = "No. cylinders must be 4, 6, or 8", column = cyl, values = c(4, 6, 8) ) affirm_close()
A data set containing demographics for enrolled subjects in a trial.
DM
DM
A data frame
Subject ID
Age at Randomization
Race
Prepend DF Name to Column Names
prepend_df_name( data, df_name = NULL, include = c(everything(), -any_of(getOption("affirm.id_cols"))) )
prepend_df_name( data, df_name = NULL, include = c(everything(), -any_of(getOption("affirm.id_cols"))) )
data |
a data frame |
df_name |
string indicating the data frame name to prepend to the column names. If not supplied, function will try to identify the data frame name. NOTE: We can only get the correct name if the data frame has been piped directly to this function without any other piped function between. |
include |
tidyselect expression to identify columns to modify name.
Default is all columns, except those identified in |
a data frame
DM |> prepend_df_name()
DM |> prepend_df_name()
A data set containing randomization assignment from a trial.
RAND
RAND
A data frame
Subject ID
Randomization Assignment
Randomization Strata Value