Learn R Programming

assertions (version 0.1.0)

has_class: Check object is some class

Description

This function checks whether object is a specific class

Usage

has_class(x, class)

Value

A logical scalar indicating x belongs to class

Arguments

x

A value to check.

class

checks if x belongs to class. If multiple values of class are supplied, returns whether x belongs to any of them (character)

Examples

Run this code
if(interactive()) {
  has_class(1, "numeric") # TRUE
  has_class(1, "character") # FALSE
}

Run the code above in your browser using DataLab