[R] S4 : package creation

Martin Morgan mtmorgan at fhcrc.org
Fri Mar 21 18:29:29 CET 2008


Hi Christophe -- 

In terms of documentation, see ?promptClass, ?promptMethods.

I don't think the description of package creation in 'S4 Classes in 15
pages, more or less' is the way things are generally done these
days. A package might normally look like

DESCRIPTION
NAMESPACE
R/AllClasses.R
R/methods-SomeClass.R

The content and organization of the files in the R directory are up to
the package author, but consist of the usual

setClass("A", ...
setMethod("foo", ...

as well as other code. The content of DESCRIPTION and NAMESPACE are
described in the 'Writing R Extensions' manual; important points are
to Depends: methods and LazyLoad: yes in the DESCRIPTION file. It is
also good to arrange that the files in the R directory are sourced in
such a way that classes are defined before the methods that use them
(using Collate: in the DESCRIPTION).

There are a number of example packages available, including those
written specifically for illustrating these issues. Several of these
were referenced in recent threads on this news group, or perhaps it
was the R-devel news group.

Martin

Christophe Genolini <cgenolin at u-paris10.fr> writes:

> Hi the list,
>
> Using S4, how can we create a package? In "S4 Classes in 15 pages, more 
> or less", they put all the classes definition in a function that will be 
> called at the opening of the library and they add "by hand" a Rd file. 
> Is it the only way ? Is there something like "S4.package.skeleton"?
>
> Thanks
>
> Christophe
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M2 B169
Phone: (206) 667-2793



More information about the R-help mailing list