Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load rda files in data folder #102

Open
ccshao opened this issue Jun 17, 2022 · 0 comments
Open

load rda files in data folder #102

ccshao opened this issue Jun 17, 2022 · 0 comments

Comments

@ccshao
Copy link

ccshao commented Jun 17, 2022

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant