Description Usage Arguments Examples
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
.
1 | instanceOf(expected)
|
expected |
object passed to the matcher function. |
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.