check_class | R Documentation |
check_class
determines whether a vector's class is among those specified.
check_class(
x,
classes = c("numeric", "integer", "logical", "character", "factor", "ordered"),
strict = TRUE
)
x |
the vector to check against specified classes. |
classes |
a character vector of classes against which x is checked. |
strict |
If TRUE, all of x's classes must be among those specified in the classes argument. If FALSE, at least one but not necessarily all of x's classes must be among those specified in the classes argument. |
By default (strict = TRUE), if a vector is of multiple classes, all of its classes must be among those specified via the classes argument.
a 1L logical vector indicating whether x's class is found among those passed to the classes argument.
check_class(mtcars$mpg) # TRUE
check_class(mtcars$mpg, classes = c("numeric", "factor")) # TRUE
check_class(iris$Species) # TRUE
check_class(iris$Species, classes = c("logical", "numeric")) # FALSE
check_class(mtcars$mpg, classes = c("logical", "character", "factor")) # FALSE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.