Description Usage Arguments Value Examples
Match variable class with the one specified and abort by 'abort' otherwise.
1 |
var |
variable to check |
type |
class to check var for |
fun_name |
required function name for error message, as character |
n |
numeric to also check length var |
allowNULL |
allow to pass check if var NULL? FALSE by default |
silent if check is passed, rlang error otherwise
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | id <- "chr"
check_class(id, "character")
id <- 2
check_class(id, "numeric")
# check variable type and length
check_class(id, "numeric", n = 1)
# pass check if variable NULL
id <- NULL
check_class(id, "character", allowNULL = TRUE)
## Not run:
# generates error
id <- 2
check_class(id, "character")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.