[Rd] S4 objects in the data directory

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


Hi

[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?

cheers

Robin

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

[snip]

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

le112:~%

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

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
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