On Jun 27, 2008, at 1:44 PM, baptiste Auguié wrote:

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.

I don't think there's any particular name needed for the file. I had a look at Matrix for an example when I was writing an S4 package, and kind of followed what they were doing. In my example, I had one file that had all the setGeneric calls, and another one named after my S4 class containing setClass and setMethod. And then you need to work on the NAMESPACE file. I think to some extent this is described in "1.6.6 Name spaces with formal classes and methods".

Hopefully someone more experienced than me can offer a more authoritative answer.

Many thanks,

Sincerely,

Baptiste

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College

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)
powerpc-apple-darwin8.10.1

locale:
en_GB.UTF-8/en_US.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8

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


_____________________________

Baptiste Auguié

Physics Department
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
http://projects.ex.ac.uk/atto


______________________________________________
R-help@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.

Reply via email to