[R] exporting methods/classes

Uwe Ligges ligges at statistik.uni-dortmund.de
Tue Jan 10 12:12:42 CET 2006


Jean-Christophe BOUETTE wrote:

>>---------- Message transféré ----------
>>From: Uwe Ligges <ligges at statistik.uni-dortmund.de>
>>To: Erin Hodgess <hodgess at gator.dt.uh.edu>
>>Date: Sun, 08 Jan 2006 15:09:06 +0100
>>Subject: Re: [R] exporting methods/classes
>>Erin Hodgess wrote:
>>
>>
>>>Dear R People:
>>>
>>>I'm still struggling with sending methods and classes as part of
>>>creating a new package.
>>>
>>>Where does the .onLoad function go?  Within R itself or in a file
>>>in one of the new package directories?
>>
>>Simply save the .onLoad function in some .R file (e.g. zzz.R) in the
>>package's ./R directory.
>>
>>
>>
>>
>>>Here are my latest efforts:
>>>
>>>
>>>Here's the last part of the woof1-Ex.Rout
>>>
>>>
>>>
>>>>library('woof1')
>>>
>>>Error in loadNamespace(package, c(which.lib.loc, lib.loc),
>>>keep.source = keep.source) :
>>>      in 'woof1' classes for export not defined: dog
>>>Error: package/namespace load failed for 'woof1'
>>>Execution halted
>>
>>So this looks like you have defined S4 classes for export in your
>>Namespace but you have no call that starts with
>>
>>setClass("dog", ......
>>
> 
> Well, it's not that easy for a newbie (like me) to track that problem.
> Using package.skeleton() (on my old R 2.1.1) puts all the function
> definitions in the ./R subdirectory, but not the call to setClass (or
> did I make something wrong?). Maybe it's one of the things that should
> be documented to make package creation easier. Of course, I know
> somebody will point me to some doc where it is stated but the fact is
> that it was not obvious.

Well, according to the documentation, package.skeleton "saves functions 
and data to appropriate places" (but not calls like setClass() and friends).

Please consider package.skeleton() only as a function that helps to set 
up the basic directory structure and required files. You have to edit 
the files afterwards, and add stuff like the mentioned calls to all 
those S4 generators.


> By the way, I'd like to thank Uwe Ligges and Duncan Murdoch for the
> helpful article in R-Help 5/2, it was really useful to me. If I manage

Nice to hear (you mean R News, though), thank you.
Although I still do not understand why it helps so much more to have 
those examples (compared to the information given in the manual).

Uwe Ligges



> to understand all the steps necessary to make an S4 namespace package
> I promise to write a "S4 Package step by step for newbies" :-)
> 
> Regards,
> Jean-Christophe Bouëtté.
> 
> 
> 
>>in the R code in your package, hence the class "dog" is undefined.
>>
>>
>>
>>>Here's the NAMESPACE
>>>importFrom(graphics,plot)
>>>exportClasses("dog")
>>>exportMethods("plot","show")
>>
>>
>>You don't export any other functions?
>>
>>
>>Uwe Ligges
>>
>>
>>
>>
>>
>>>thanks yet again,
>>>Sincerely,
>>>Erin
>>>mailto: hodgess at gator.uhd.edu
>>>
>>>______________________________________________
>>>R-help at stat.math.ethz.ch mailing list
>>>https://stat.ethz.ch/mailman/listinfo/r-help
>>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>>
>>
>>
>>
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list