Checks if object
inherits the data.frame class.
If the not
tbl_check_is_table()
returns a list describing the problemtbl_grade_is_table()
returns a failing grade and informative message withgradethis::fail()
Usage
tbl_check_is_table(object = .result, env = parent.frame())
tbl_grade_is_table(object = .result, env = parent.frame(), ...)
Arguments
- object
An object to be compared to
expected
.- env
The environment in which to find
.result
and.solution
.- ...
Arguments passed on to
gradethis::fail
hint
Include a code feedback hint with the failing message? This argument only applies to
fail()
andfail_if_equal()
and the message is added using the default options ofgive_code_feedback()
andmaybe_code_feedback()
. The default value ofhint
can be set usinggradethis_setup()
or thegradethis.fail.hint
option.encourage
Include a random encouraging phrase with
random_encouragement()
? The default value ofencourage
can be set usinggradethis_setup()
or thegradethis.fail.encourage
option.
Value
If there are any issues, a list from tbl_check_is_table()
or a
gradethis::fail()
message from tbl_grade_is_table()
.
Otherwise, invisibly returns NULL
.
Examples
.result <- data.frame(a = 1:10)
tbl_check_is_table()
tbl_grade_is_table()
.result <- tibble::tibble(a = 1:10)
tbl_check_is_table()
tbl_grade_is_table()
.result <- list(a = 1:10)
tbl_check_is_table()
#> <tblcheck problem>
#> Your result should be a table, but it is a list (class `list`).
#> $ type : chr "not_table"
#> $ expected : chr "data.frame"
#> $ actual : chr "list"
#> $ actual_length: int 1
tbl_grade_is_table()
#> <gradethis_graded: [Incorrect]
#> Your result should be a table, but it is a list (class `list`).
#> >