[英]Cannot document my R package 'NAMESPACE' issue
I am try to write my first R package and start a piece of test function. 我试图编写我的第一个R包并启动一个测试功能。 When I create a brand new package, I get a sample 'Hello.R' in R folder and 'Hello.Rd' in Man folder.
当我创建一个全新的程序包时,在R文件夹中有一个示例“ Hello.R”,在Man文件夹中有一个示例“ Hello.Rd”。
Then I delete the helloworld test function and type in my test code, wrote the documentation and try to create a new documentation: 然后,我删除helloworld测试函数并输入测试代码,编写文档并尝试创建新文档:
#' A Cat Function
#'
#' This function allows you to express your love of cats.
#' @param love Do you love cats? Defaults to TRUE.
#' @keywords cats
#' @export
#' @examples
#' cat_function()
cat_function <- function(love=TRUE){
if(love==TRUE){
print("I love cats!")
}
else {
print("I am not a cool person.")
}
}
devtools::document()
Then I got this error: 然后我得到了这个错误:
> devtools::document()
Updating cat2 documentation
Loading cat2
First time using roxygen2. Upgrading automatically...
Updating roxygen version in /Users/daisywang/Desktop/R Package Programming/cat2/DESCRIPTION
Warning: The existing 'NAMESPACE' file was not generated by roxygen2, and will not be overwritten.
Warning messages:
1: In readLines(file) :
incomplete final line found on '/Users/daisywang/Desktop/R Package Programming/cat2/DESCRIPTION'
2: In readLines(file) :
incomplete final line found on '/Users/daisywang/Desktop/R Package Programming/cat2/DESCRIPTION'
Then I tried to delete the "NAMESPACE" file in the folder, and got an infinite error: 然后,我尝试删除文件夹中的“ NAMESPACE”文件,并收到一个无限错误:
Updating cat2 documentation
Loading cat2
Show Traceback
Rerun with Debug
Error in dev_meta(pkg$package) (from hello.R#19) :
Namespace not found for cat2. Is it loaded?
Any insight appreciated!! 任何见解表示赞赏!
The line devtools::document()
should not be part of your hello.R
(or cat.R
) file. devtools::document()
不应属于hello.R
(或cat.R
)文件。 This function is only meant to be called directly from the terminal. 该功能只能直接从终端调用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.