[Rd] check warning with .onLoad() and setClass()

Rainer M Krug Rainer at krugs.de
Fri Oct 4 16:07:59 CEST 2013


Dirk Eddelbuettel <edd at debian.org> writes:

> On 4 October 2013 at 14:15, Rainer M Krug wrote:
> | Hm. loadModule is Rcpp function, but I am only interested in using the
> | setClass() function, which has nothing to do with Rcpp. I don't even use
> | Rcpp in the package, only in one which is imported.
>
> Sorry, assumed Reference Class created via Modules. My bad, and never mind.
>
> But as John said, .onLoad() can be replaces since he made those changes in R
> (and also in Rcpp). See ?setLoadAction, evalOnLoad(), ...

Ok - theat far I folow you. But how do I implement this?

I have now the following .onLoad() function:

,----
| .onLoad <- function(libname, pkgname) {
|     setClass(
|         "inDrak",
|         representation(
|             init = "SpatialGridDataFrame"
|             ),
|         contains = "simObj"
|         )
| }
`----

in the file ./R/onLoad.R in my package.

Now how can I now use the setLoadFunction()? I tried to simply put the
setClass in the setLoadFunction() as follow into the ./R/onLoad.R file:

,----
| setLoadFunction( function(libname, pkgname) {
|     setClass(
|         "inDrak",
|         representation(
|             init = "SpatialGridDataFrame"
|             ),
|         contains = "simObj"
|         )
| }
`----

but this did not work. 

So what do I have to do with it? I only find very few examples using
setLoadFunction().

Rainer


>
> Dirk


-- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      Rainer at krugs.de

Skype:      RMkrug



More information about the R-devel mailing list