I'm developing an R package, pk
, say. I've successfully installed it and used it, and now I'm trying to clean up the examples with the help of the run_examples
function in the devtools
package. However, it crashes on the very first example:
> require(pk)
> require(devtools)
> run_examples("~/[full path]/pk")
Updating pk documentation
Running 45 example files in pk
--------------------------------------------------------------------------------
Loading pk
Running examples in pk-package.Rd
--------------------------------------------------------------------------------
1> ########################################################################
1> ## Simulate a dataset ... blah blah
1> set.seed(1)
1> x = my_pk_fun(a = 1)
Error in eval(expr, envir, enclos) : could not find function "my_pk_fun"
Loading pk
As I already loaded my package (using require
), what more do I have to do to make my_pk_fun
visible to run_examples
? I've checked that my_pk_fun
is indeed present in my R session.
UPDATE:
Following the comment by Dirk, I examined my namespace file, and found it to be completely empty. As suggested (though not recommended) by the documentation, I inserted exportPattern("^[^\\.]")
, which, it seems, is supposed to export all of the functions, including my_pk_fun
. However, upon repeating the experiment above, (a) I get the same error, and (b) the contents of the namespace file are deleted! Why does run_examples
empty my namespace file?