Roxygen2: “Error in loadNamespace(name) : there is

2019-09-21 10:29发布

问题:

This is a follow up from a previous question.

How to integrate new R6Class functions stored in independent files into an existing R package?

In summary, in trying to load a function stored in a file. I managed to do it by altering manually the NAMESPACE and Collate in the DESCRIPTION and rebuilding the package. However, I am sure this is not standard practice since the package already has a man folder and .Rd files created with roxygen2. However, when I try to use roxygen2 to manage my NAMESPACE and Collate in the DESCRIPTION, the following error pops up.

==> devtools::document(roclets=c('rd', 'collate', 'namespace'))

Updating mypackage documentation
Loading mypackage
Error in loadNamespace(name) : there is no package called ‘testthat’
Calls: suppressPackageStartupMessages ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted

Exited with status 1.

The working directory contains a folder tests with a testhat.R file and a second folder full of functions.

Any hint of why roxygen2 is falling to produce the documentation and update the NAMESPACE and DESCRIPTION?

回答1:

You need to install the testthat package


testthat is a package that is

A unit testing system designed to be fun, flexible and easy to set up.

The test section of Hadley's R Packages book (online) is a good guide on how to use it.

In fact, I recommend going through the whole book as it will introduce you to some best-practices for creating packages. I've used it a lot!



标签: r class r6