I am writing an R function, and I want to make sure that the argument of my R function is of a certain class (eg, \"matrix\").
What is the best way to do this?
S
Just for completeness: besides
is.matrix(foo)
you can also test for
class(foo) == "matrix"
which also works for non-standard that do not have is.foo() functions.
is.foo()