我正在嘗試準備一個包以提交給CRAN。在我的DESCRIPTION文件中,我將非CRAN包包含在Depends和Suggests參數中。爲了告訴R在哪裏找到非CRAN包,我包含了Additional_repositories參數;並且在我的程序的頂部包含一個.onLoad函數(即'zzz.R')。只要所有Depends和Suggests包都存在,我就可以在RStudio中構建並檢查(--as-cran),併發出零警告,註釋或錯誤。然後我使用devtools :: build()在本地創建一個.tar.gz文件。未從Additional_repositories安裝R包依賴項(重新訪問)
爲了測試本地安裝是否成功,我從計算機中刪除了非CRAN軟件包,並嘗試安裝我創建的.tar.gz文件。然後我得到的消息:
ERROR: dependency 'smwrQW' is not available for package 'baytrends'
我已經通過
- R package dependencies not installed from Additional_repositories
- Include non-CRAN package in CRAN package
- http://thecoatlessprofessor.com/programming/r-data-packages-in-external-data-repositories-using-the-additional_repositories-field/
- How should I deal with "package 'xxx' is not available (for R version x.y.z)" warning?
不幸閱讀但是,上述錯誤仍在繼續。我相信我使用的URL,因爲當獨立運行下面的install.package線工程
install.packages('smwrQW',repos=c("http://owi.usgs.gov/R"),dependencies = TRUE)
描述和zzz.R文件的適用位低於:
描述:
Date: 2017-03-15
Depends:
R (>= 3.2.0),
lubridate,
mgcv,
smwrQW
License: GPL-3
LazyData: TRUE
RoxygenNote: 6.0.1
Suggests:
dataRetrieval,
devtools,
fitdistrplus,
knitr,
nlme,
pander,
plyr,
rmarkdown,
smwrBase,
smwrGraphs,
smwrStats,
testthat
Additional_repositories: http://owi.usgs.gov/R
VignetteBuilder: knitr
zzz.R:
.onLoad <- function(libname = find.package("baytrends"), pkgname = "baytrends"){
repos = getOption("repos")
repos["USGS"] = "http://owi.usgs.gov/R"
options(repos = repos)
invisible(repos)
# declaration of global variables (https://stackoverflow.com/questions/9439256)
if(getRversion() >= "2.15.1")
utils::globalVariables(c("begin", "methodsList"))
invisible()
}
.onAttach <- function(libname = find.package("baytrends"), pkgname = "baytrends"){
packageStartupMessage("This software program is preliminary or provisional and is subject to revision. ")
}
謝謝。我將smwrQW移至Suggests:並得到了「不需要命名空間的依賴關係:'smwrQW'」錯誤。我查看了http://stackoverflow.com/questions/13085481/namespace-dependencies-not-required,並將smwrQW移至進口:。這糾正了構建錯誤,但將我留在與原始發佈相同的地方。 – greengrass62
您還需要將其從NAMESPACE中刪除。沒有依賴,沒有進口,沒有NAMESPACE - 只有建議。 –
我創建了一些其他的錯誤。將重新啓動測試包並實施您的建議。 – greengrass62