Dear R-Users and R-Devels,

I am programming a package with S4 classes and I search for a solution of the 
following problem: 

If you want an S4 method to await an integer argument you set the signature 
like this

setMethod("myfunction", signature(object = "myClass", y = "integer"), 
function(object, y) {//Do sth})

Now, if you want the method to await an integer matrix or array there is only 
one way how to define it

setMethod("myfunction", signature(object = "myClass", y = "matrix"), 
function(object, y) {//Do sth}) or
setMethod("myfunction", signature(object = "myClass", y = "array"), 
function(object, y) {//Do sth}) 

am I right? WIth this you can also pass a numeric matrix.

How would you check for an integer matrix in an S4 method (in the index 
function of R I think it is just coerced to integer)? Furthermore: How would 
you check for an integer matrix with values 
bigger one (so the typical R indices)? Is there a way how it is usually done in 
R (I think probably with apply())? Or is it usually better to throw an 
exception?


Best

Simon

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to