Ross Boylan wrote:
I can't tell from the docs  ("Writing R Extensions" 1.9.1) exactly what
environment the tests, examples, and vignettes that R CMD check tries to
run are in.

In particular:
1) how do I get the package loaded?
2) how do I access data in the data/ directory?
3) where is the material in the other directories?  (e.g., has inst/
material been installed?  where?)

Apparently (section 1.3) stuff in demo/ is not checked, which seems odd.

By inspecting some other packages, it seems the answer to 1) is that the
package is already loaded, so I don't need to say library(...).  In
particular, I don't need to figure out what lib.loc is.

I have some C code as part of the package, so that (well the .so file)
needs to be loaded too.

Yes. You don't need library() in the the help pages' exmaples, but you need it in tests.



2) Others seem to just say data(..), but this doesn't work for me.
I created the data with
save(gold, e2, q2, file="mspath/data/inputs", compress=TRUE)
and later renamed the file to inputs.RData.  (check didn't think the
file counted without the extension).

Indeed, the manuals tells us that saved images have to be called either *.RData (note the capitalization) or *.rda.


I have tried to access it in my test script (under tests/) with both
load and data (e.g., data("inputs"), data("inputs.RData"),
data(inputs)).  I get

data(inputs)

Warning message: Data set 'inputs' not found in: data(inputs)

Works for me as "Mytests.R" in "Mypackage":

 library(Mypackage)
 data(MydataInMypackage)
 print(MydataInMypackage)



For that matter, my assumed answer to 1) doesn't seem to be working out,
because when I try to access one of my functions it tells me it can't
find it.  The function name is the same as the package name.

Perhaps the problem is I have inferred answers from \example{}, and the
story for tests/ is different.

Right, see above.


Although I'm currently focussed on running a script in tests/, I'd like
to know what the story is for \examples in documentation or vignettes.

You won't need library() in the examples ...


Thanks.

P.S. Is there a typical way to produce the .Rout.save file used in
tests/?  What I'm doing is a slightly awkward 2-step process.


Running R CMD check once, looking whether the Rout looks fine (this should be the step that takes most of the time, and R can't do it for you), rename the file it, finished.


Uwe Ligges

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to