[Rd] Some more help on S4 mechanism

From: Renard Didier <didier.renard_at_mines-paristech.fr>
Date: Mon, 22 Mar 2010 13:31:02 +0100

Hello to the list

Some days ago, I placed a question on this maling-list and received an answer from Martin
that I tried to follow. Unfortunately, I am still puzzled by the next step. I spent the whole Week-end in gathering information from the net.
Some of them are almost contridtcory and I lack a good document to help me. So my first question would beL Is there a convenient document which tells a standard user, who laready developped a package with S3, on how to migrate to the S4 mechanism.

Secondly, this is my problem:
According to Martin, now I use a NAMESPACE (as follows):

import (methods)






More over, in the R directory, I have a zzz.lib with the following contents (.onLoad) :

".onLoad" <-

        # Define the Classes #

        # Define the environment variables #


The file All0.Classes (which will not be exported ... see exportPattern) contains
all the class definitions (setClass functions)

Finally, I have some other functions, such as db.plot, which contain the following statement
(at the end of the file):

setMethod("plot", signature(x="db"), function(x,y,...) db.plot(x,...))

My questions:
- Should the setMethods be regrouped in a single file (as I read from the net).
- What are the differences between "R CMD check" and "R CMD INSTALL" as far as the steps are involved.

As a matter of fact:
- R CMD check finds that everything is OK - R CMD INSTALL gives me a set of warnings of the following type:

Warning in matchSignature(signature, fdef, where) :   in the method signature for function "[<-" no definition for class: "db" I did not use the Collate option (that Martin suggested) as I am not sure of its syntax and where I should add these statements.

The package works fine anyhow but I would like to correct these warnings.

By the way, as I belong to an institute where we use Fedora Core 8, I am stuck with R 2.8.0.

An ultimate problem: I develop two packages P1 and P2 where P2 requires P1. So I used the same architecture for both with NAMESPACE and .onLoad functions (in the zzz.lib files).

For P2, I mention that it depends upon P1 in the DESCRIPTION file. This information seems redundant with the NAMESPACE where I can add "import(P1)". Finally when, as a user, I load both by library() (first P1 then P2), I receive a message about function .onLoad being loaded twice.

How can I avoid this.

As you can see, I encountered several problems when converting my S3 into S4. I would appreciate if someone could give me a complete information and a godd reference.

Thanks in advance.

Centre de Geosciences / Geostatistique
Ecole des Mines de Paris
35 Rue St Honore
77300 Fontainebleau

Tel: (1) 64 69 47 80
Fax: (1) 64 69 47 05

______________________________________________ R-devel_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Received on Mon 22 Mar 2010 - 16:28:24 GMT

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 Mon 22 Mar 2010 - 18:21:15 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