tommy chheng
tommy chheng

Reputation: 9228

How can I specify the working directory while running R CMD check?

The command R CMD check runs the R files in the project's tests directory.

The directory structure:

toplevel
  project
    R
      rmongo.R
    tests
      RMongo-Ex.R

When I R CMD check project in toplevel directory, i run into this error:

cannot open file '../R/rmongo.R': No such file or directory

because my test file sources the R code file source('../R/rmongo.R', chdir = TRUE)

How can I make R CMD check cd into the test directory before running test file?

Upvotes: 1

Views: 652

Answers (1)

tommy chheng
tommy chheng

Reputation: 9228

The files in tests are test against the package after it's built so I just included library('name-of-package') in the test file and it was able to build.

Upvotes: 2

Related Questions