instanceOf: Returns a function that checks whether its 'argument' is...

Description Usage Arguments Examples

View source: R/hamcrest.R

Description

Checks if the value is an instance of a class. The expected value checks where the class name of the actual object is inherited. This is about checking S3 and S4 classes and the call uses the base function inherits.

Usage

1
instanceOf(expected)

Arguments

expected

object passed to the matcher function.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
res <- lm(Petal.Length ~ Petal.Width, iris)
assertThat(res, instanceOf("lm"))

df <- data.frame(x = c(1, 1, 1, 2, 2, 3, 3), y = c(1, 2, 3, 4, 5, 6, 7))
res <- by(df$y, df$x, sum)
assertThat(res, instanceOf("by"))

class(df) <- "result"
assertThat(df, instanceOf("result"))

## End(Not run)

bedatadriven/hamcrest documentation built on Dec. 1, 2019, 1:49 p.m.