Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
325 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 Reply

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...