Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
330 views
in Technique[技术] by (71.8m points)

r - Roxygen2: "Error in loadNamespace(name) : there is no package called ‘testthat’"?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...