[Rd] S4 objects in the data directory

From: Robin Hankin <rksh1_at_cam.ac.uk>
Date: Thu, 12 Nov 2009 09:50:15 +0000


[R-2.10.0; suse linux]

I am having difficulty creating S4 objects in the data directory of a package. I want
to create a bunch of simple S4 objects for use in the examples section of the Rd files.

It says in R-exts that:

" R code should be “self-sufficient” and not make use of extra functionality provided by the package, so that the data file can also be used without having to load the package"

My current minimal self-contained example follows.

le112:~% cat ./anRpackage/R/f.R
setClass("foo", representation=representation(x="numeric"))

le112:~% cat ./anRpackage/data/toy_foo.R "toy_foo" <- new("foo",x=rep(2,7))

fails R CMD check (transcript below)

It fails because the class isn't defined. I can add 'require(anRpackage)' to the toy_foo.R but I'm not sure if this is consistent with the above advice in R-exts (and it
fails R CMD check anyway).

What is best practice for creating a package with "toy" S4 objects for use in the examples section of the Rd files?



le112:~% R CMD check ./anRpackage
* checking for working pdflatex ... OK


WARNING: There were 2 warnings, see
/home/rksh/anRpackage.Rcheck/00check.log for details


Robin K. S. Hankin
Uncertainty Analyst
University of Cambridge
19 Silver Street
Cambridge CB3 9EP

R-devel_at_r-project.org mailing list
Received on Thu 12 Nov 2009 - 09:55:00 GMT

This archive was generated by hypermail 2.2.0 : Thu 12 Nov 2009 - 11:50:23 GMT