[Rd] S3 generic/method consistency issue with R CMD check

From: Drew Schmidt <schmidt_at_math.utk.edu>
Date: Wed, 21 Nov 2012 11:19:39 -0500 (EST)


Hi,

I'm having some trouble setting methods for the qr family of functions. I believe I have distilled my misunderstanding in the code snippet below:

foo <- function(x, ...) UseMethod("foo")

foo.default <- function(x) { }

# foo

setGeneric(name = "foo", useAsDefault = foo)

setMethod("foo", signature(x="bar"),
  function(x, ...) { }
)

setGeneric(name="foo.Q",
  function(y, ...)
    standardGeneric("foo.Q")
)

setMethod("foo.Q", signature(y="bar"),
  function(y, ...) { }
)

# QR

setGeneric(name = "qr", useAsDefault = qr)

setMethod("qr", signature(x="bar"),
  function(x, ...) { }
)

setGeneric(name="qr.Q",
  function(y, ...)
    standardGeneric("qr.Q")
)

setMethod("qr.Q", signature(y="bar"),
  function(y, ...) { }
)

If you send this to R CMD check, then it gives exactly one WARNING about S3 consistency:

This seems to be complaining about the fact that qr.Q dispatches on 'y' instead of 'x'. But there is no complaint about foo/foo.Q even though, I believe, the only difference is a mechanical substitution of generic/method names.

Ultimately I would like to be able to set methods for the qr family in a way that maximally mimics R in both syntax and return. I'm clearly doing something wrong, but I'm not really sure how else to proceed. Any help in clearing up my misunderstanding here would be greatly appreciated.

Thanks.

-- 
Drew Schmidt
National Institute for Computational Sciences
University of Tennessee

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Wed 21 Nov 2012 - 16:29:49 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 29 Nov 2012 - 03:31:37 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive