I am trying to understand why the code included in the @examples section of a package I am working on produces different outputs depending if it runs using devtools::run_exmaples()
or devtools::check()
From time to time I included in the example code like, e.g.:
stopifnot(nrow(x) == 5540)
When I run the code by copy pasting it into the R console it produces NO errors, If I run it using devtools::run_examples()
there are no errors, however when the examples are executed using devtools::check()
or R CMD check
the example check fails with:
> stopifnot(nrow(x) == 5540)
Error: nrow(x) == 5540 is not TRUE
What might be the reason for it? What should I look into? are the examples run in a different environment? Is it the order of the examples that changes? Are there side effects? Is it possible that the lib.path
is different?