See https://adv-r.hadley.nz/oo.html for an overview of R's OO systems, and the vocabulary used here.
expect_type(x, type) checks that
expect_s3_class(x, class) checks that
x is an S3 object that
expect_s3_class(x, NA) checks that
x isn't an S3 object.
expect_s4_class(x, class) checks that
x is an S4 object that
expect_s4_class(x, NA) checks that
x isn't an S4 object.
expect_vector() for testing properties of objects created by vctrs.
1 2 3 4 5
Object to test.
Supports limited unquoting to make it easier to generate readable failures within a function or for loop. See quasi_label for more details.
String giving base type (as returned by
Either a character vector of class names, or
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
x <- data.frame(x = 1:10, y = "x", stringsAsFactors = TRUE) # A data frame is an S3 object with class data.frame expect_s3_class(x, "data.frame") show_failure(expect_s4_class(x, "data.frame")) # A data frame is built from a list: expect_type(x, "list") # An integer vector is an atomic vector of type "integer" expect_type(x$x, "integer") # It is not an S3 object show_failure(expect_s3_class(x$x, "integer")) # Above, we requested data.frame() converts strings to factors: show_failure(expect_type(x$y, "character")) expect_s3_class(x$y, "factor") expect_type(x$y, "integer")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.