load rda files in data folder
First thanks for the nice package!
I include two tests in my package, and test_all(".") runs fine. The test codes loads data from data folder:
load("../../data/example_z.rda")
load("../../data/comp_mut.rda")
However, after building the packge, R CMD check fails with the following error:
* checking tests ...
Running ‘tinytest.R’
ERROR
Running the tests in ‘tests/tinytest.R’ failed.
Complete output:
> if (requireNamespace("tinytest", quietly = TRUE)) {
+ tinytest::test_package("mslp")
+ }
Loading required package: data.table
Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection
Calls: <Anonymous> ... run_test_dir -> lapply -> FUN -> eval -> eval -> load -> readChar
In addition: Warning message:
In readChar(con, 5L, useBytes = TRUE) :
cannot open compressed file '../../data/example_z.rda', probable reason 'No such file or directory'
Execution halted
I think that checking tests could not get the correct path of data.
However, in the vignettes, it is stated that:
When your package is tested with test_package, tinytest ensures that your working directory is the testing directory (by default tinytest). This means you can read files that are stored in your folder directly. Suppose that your package directory structure looks like this (default): /inst /tinytest /test.R /women.csv Then, to check whether the contents of women.csv is equal to the built-in women dataset, the content of test.R looks as follows. R> dat <- read.csv("women.csv") R> expect_equal(dat, women)
So I'm confused about the proper way of loading data. Suggestions are really appreciated, thanks!