Roxygen2: “Error in loadNamespace(name) : there is no package called ‘testthat’”?

那年仲夏 提交于 2019-12-13 10:51:50

问题


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!



来源:https://stackoverflow.com/questions/37555870/roxygen2-error-in-loadnamespacename-there-is-no-package-called-testthat

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!