View source: R/tbl_check_column.R
tbl_check_column | R Documentation |
Checks for differences between the name
column in object
and in
expected
in the following order:
Check that the name
column exists in object
Check class with vec_check_class()
Check length with vec_check_dimensions()
If the column is a factor, check factor levels with vec_check_levels()
Check column values with vec_check_values()
If the columns differ
tbl_check_column()
returns a list describing the problem
tbl_grade_column()
returns a failing grade and informative message
with gradethis::fail()
tbl_check_column( column, object = .result, expected = .solution, check_class = TRUE, ignore_class = NULL, check_length = TRUE, check_levels = TRUE, check_values = TRUE, tolerance = sqrt(.Machine$double.eps), check_names = FALSE, env = parent.frame() ) tbl_grade_column( column, object = .result, expected = .solution, max_diffs = 3, check_class = TRUE, ignore_class = NULL, check_length = TRUE, check_levels = TRUE, check_values = TRUE, tolerance = sqrt(.Machine$double.eps), check_names = FALSE, env = parent.frame(), ... )
column |
|
object |
A data frame to be compared to |
expected |
A data frame containing the expected result. |
check_class |
|
ignore_class |
If an element is named, differences will only be ignored between the pair
of the element and its name.
For example, If all the classes of |
check_length |
|
check_levels |
|
check_values |
|
tolerance |
|
check_names |
|
env |
The environment in which to find |
max_diffs |
|
... |
Arguments passed on to
|
If there are any issues, a list from tbl_check_column()
or a
gradethis::fail()
message from tbl_grade_column()
.
Otherwise, invisibly returns NULL
.
names
(table_problem
): object
doesn't contain a column named column.
class
: Any mismatch in the classes of the column
.
length
: The column
doesn't have the expected length.
levels_n
, levels
, levels_reversed
, levels_order
:
See vec_check_levels()
.
values
: The column
doesn't have the expected values.
names
(column_problem
): The column
has different names
than expected.
names_order
: The column
has the same names as expected,
but in a different order.
.result <- tibble::tibble(a = 1:10, b = 11:20) .solution <- tibble::tibble(a = letters[1:10], b = letters[11:20]) tbl_check_column("a") tbl_grade_column("a") .result <- tibble::tibble(a = 1:10, b = 11:20) .solution <- tibble::tibble(a = 1:11, b = 12:22) tbl_check_column("a") tbl_grade_column("a") .result <- tibble::tibble(a = 1:10, b = 11:20) .solution <- tibble::tibble(a = 11:20, b = 1:10) tbl_check_column("a") tbl_grade_column("a") tbl_grade_column("a", max_diffs = 5) tbl_grade_column("a", max_diffs = Inf)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.