A wrapper for affirm_true()
.
Reports columns
that do not inherit class
, e.g.
select(data, all_of(columns) && where(\(x) !inherits(x, class)))
A wrapper for affirm_true()
.
The columns argument is used to construct the
affirm_true(condition = is.na(column))
argument.
Usage
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_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)
)
Arguments
- 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.
id
must be an integer, e.g.id = 1L
priority
must be an integer, e.g.priority = 1L
data_frames
string of data frame names used in affirmation, e.g.data_frames = "RAND, DM"
- report_listing
an expression selecting/filtering rows from
data=
to return in the issue listing report. The default is to return the result fromcreate_report_listing()
, which are the rows that do not met incondition=
and columns included in thecondition=
expression along with any columns set inoption('affirm.id_cols')
. The'affirm.id_cols'
option must be a character vector of column names, where columns will be selected withselect(any_of(getOption('affirm.id_cols')))
.- data_action
this expression is executed at the end of the function call when supplied.
Default is NULL, and the passed data frame in
data=
is returned unaltered.Perhaps you'll need to remove problematic rows:
data_action = filter(., !(!!condition))
- error
Logical indicating whether to throw an error when condition is not met. Default is
FALSE
.- column
column to check NA values against
See also
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()
Examples
affirm_init(replace = TRUE)
#> ✔ We're ready to make data affirmations...
affirm_class(
as_tibble(iris),
label = "all cols are numeric (but Species really isn't)",
columns = everything(),
class = "numeric"
)
#> • all cols are numeric (but Species really isn't)
#> 1 issue identified.
#> # A tibble: 150 × 5
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> <dbl> <dbl> <dbl> <dbl> <fct>
#> 1 5.1 3.5 1.4 0.2 setosa
#> 2 4.9 3 1.4 0.2 setosa
#> 3 4.7 3.2 1.3 0.2 setosa
#> 4 4.6 3.1 1.5 0.2 setosa
#> 5 5 3.6 1.4 0.2 setosa
#> 6 5.4 3.9 1.7 0.4 setosa
#> 7 4.6 3.4 1.4 0.3 setosa
#> 8 5 3.4 1.5 0.2 setosa
#> 9 4.4 2.9 1.4 0.2 setosa
#> 10 4.9 3.1 1.5 0.1 setosa
#> # ℹ 140 more rows
affirm_close()
affirm_init(replace = TRUE)
#> ✔ We're ready to make data affirmations...