[R] include S4 class and methods in a package

From: baptiste Auguié <ba208_at_exeter.ac.uk>
Date: Fri, 27 Jun 2008 18:44:00 +0100

DeaR list,

Pardon the stupidity of this question but I've been trying this for a while now without success.

I've followed the example given in the green book "programming with data", and I now have a working example of a S4 class with a few methods (plot, summary, as.data.frame). It's all very nice in one file, but I cannot find the way to put this information in a package. I've created several simple packages (without S4 classes) in the past using package.skeleton and manual editing / adding of some files. The question I have now is where do the setClass and setMethod live in the folder tree? I sort of believe they should be defined in a source file in the sub-directory R/, but is there a special name to give to these files, how do they get recognised during installation or build?

I've tried to find the answer in "writing R extensions" but I must have missed the relevant section.

Many thanks,



PS: I'm not sure a minimal example is relevant, I could provide one if requested.

OS is MacOS 10.4,
> sessionInfo()

R version 2.7.0 RC (2008-04-21 r45421)


attached base packages:

[1] datasets  utils     stats     graphics  grDevices splines    
grid      methods   base


Baptiste Auguié

Physics Department
University of Exeter
Stocker Road,
Exeter, Devon,

Phone: +44 1392 264187


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. Received on Fri 27 Jun 2008 - 18:01:50 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 Sat 28 Jun 2008 - 19:31:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive