[英]Cannot document my R package 'NAMESPACE' issue
我試圖編寫我的第一個R包並啟動一個測試功能。 當我創建一個全新的程序包時,在R文件夾中有一個示例“ Hello.R”,在Man文件夾中有一個示例“ Hello.Rd”。
然后,我刪除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()
然后我得到了這個錯誤:
> 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'
然后,我嘗試刪除文件夾中的“ 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?
任何見解表示贊賞!
devtools::document()
不應屬於hello.R
(或cat.R
)文件。 該功能只能直接從終端調用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.