is_ | R Documentation |
Checks both the class, size and type of an object. Returns a logical or an error if false.
is_(x, class = NULL, size = NULL, type = NULL, error_on_false = F)
x |
(any object) The object to test. |
class |
(chr vector) The accepted classes. This is checked with |
size |
(num vector) The accepted lengths. This is checked with |
type |
(chr vector) The accepted types. This is checked with |
error_on_false |
(log scalar) Whether to throw an error instead of returning false (default false). |
Vectors are treated as 1-dimensional.
Logical scalar or error.
is_(iris, class = "data.frame") #check for one class
is_(iris, class = c("data.frame", "logical", "matrix")) #can check for multiple classes
is_(iris, class = "data.frame", size = c(150, 5)) #check for one class and size
is_(iris, size = c(150, 5)) #check for size
is_(iris, size = 1) #check for wrong size
is_(iris, type = "list") #check for type
!is_(iris, type = "factor") #check for wrong type
is_(iris, class = "list", error_on_false = T) #check for one class, error
is_(1:3, class = "numeric")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.