Skip to content
Prev 248424 / 398502 Next

Problem with "setMethod" in R package

On 01/26/2011 05:08 AM, Pascal A. Niklaus wrote:
Hi Pascal --

Normally one would arrange code (e.g., using the Collate: field of the
DESCRIPTION file to define S4 classes, generics, then methods, equivalent to

setClass("Foo")
setGeneric("plot")  ## promote plot to S4 generic
setMethod("plot, c(x="Foo", y="missing"), Rcpp_rothC.plot)

One would not normally specify a 'where' argument to setMethod; by
default the method is created in the 'top' environment at the time the
package is installed, which is the package name space. It is not usually
necessary to include setMethod and friends in .onLoad.

I do not use Rcpp, but one would normally have to write R code to wrap
the C++ object, e.g., an S4 class with an 'externalptr' slot to contain
the address of the object, plus methods to interact with the object.
This part of the problem sounds like a question for the Rcpp help list.

Martin