powered by
Test if an object can be coerced to a given S4 class. Maybe useful inside if() to ensure that calling as(object, Class) will find a method.
if()
as(object, Class)
canCoerce(object, Class)
any R object, typically of a formal S4 class.
an S4 class (see isClass).
isClass
a scalar logical, TRUE if there is a coerce method (as defined by e.g.setAs) for the signature (from = class(object), to = Class).
TRUE
coerce
setAs
(from = class(object), to = Class)
as, setAs, selectMethod, setClass,
as
selectMethod
setClass
# NOT RUN { m <- matrix(pi, 2,3) canCoerce(m, "numeric") # TRUE canCoerce(m, "array") # TRUE # }
Run the code above in your browser using DataLab