R 包失败的 CRAN 检查因为(r 包)矩阵不可用于依赖项

R Package Failing CRAN checks Because (r package) Matrix is not available for a dependency

我正在开发我的第一个 R 包。它是 ggplot2 的扩展,用于处理调查数据和调查包。这取决于 ggplot2、dplyr、hexbin 和调查。

当我运行在一台有依赖的机器上检查时,检查成功。但是,它对 CRAN 的检查失败,当我在 R Hub 上 运行 它时,我收到以下错误: Error : package ‘Matrix’ required by ‘survey’ could not be found.

我尝试将 Matrix 添加到 depends 但它仍然不起作用。

这是我的描述:

Package: ggsurvey
Type: Package
Title: Simplifying `ggplot2` for Survey Data
Version: 1.0.0
Author: Brittany Alexander
Maintainer: Brittany Alexander <balexanderstatistics@gmail.com>
Description: Functions for survey data including svydesign objects from the 'survey' package that call 'ggplot2' to make bar charts, histograms, boxplots, and hexplots of survey data.  
License: MIT + file LICENSE
Encoding: UTF-8
Depends: R (>= 3.5.0), ggplot2, Matrix, survey, hexbin, dplyr
Imports: stats
LazyData: true
RoxygenNote: 7.1.2

还有我的命名空间:

# Generated by roxygen2: do not edit by hand

export(ggbarcrosstabs)
export(ggbarcrosstabs3d)
export(ggbarcrosstabs3d_svy)
export(ggbarcrosstabs_svy)
export(ggbarweight)
export(ggbarweight_svy)
export(ggboxweight)
export(ggboxweight2d)
export(ggboxweight2d_svy)
export(ggboxweight3d)
export(ggboxweight3d_svy)
export(ggboxweight_svy)
export(gghexweight)
export(gghexweight2d)
export(gghexweight2d_svy)
export(gghexweight3d)
export(gghexweight3d_svy)
export(gghexweight_svy)
export(gghistweight)
export(gghistweight2d)
export(gghistweight2d_svy)
export(gghistweight3d)
export(gghistweight3d_svy)
export(gghistweight_svy)
import(dplyr)
import(ggplot2)
import(hexbin)
import(survey)

完整的 github 存储库在这里:https://github.com/balexanderstats/ggsurvey 有什么问题吗?

好的,我克隆了你的代码库(感谢你提供 link!)我明白了

   Package in Depends field not imported from: ‘Matrix’
     These packages need to be imported from (in the NAMESPACE file)
     for when this namespace is loaded but not attached.

这只是一个 'Note' 而不是错误。我看到你使用 Depends:,这些天我们有 NAMESPACE 一个 Imports: 更可取。正如消息所说,您似乎对这些包中的每一个都有一个 import,但没有 Matrix。尽管在 R/importpackages.R 中的同一行上很容易添加。有了这个,我在这里检查得很好(除了示例中的错误:could not find function "ylab" 我会留给你。

edd@rob:/tmp/TEMP/ggsurvey(main)$ git diff
diff --git a/DESCRIPTION b/DESCRIPTION
index 5396e8b..3ff45af 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -7,7 +7,7 @@ Maintainer: Brittany Alexander <balexanderstatistics@gmail.com>
 Description: Functions for survey data including svydesign objects from the 'survey' package that call 'ggplot2' to make bar charts, histograms, boxplots, and hexplots of survey data.  
 License: MIT + file LICENSE
 Encoding: UTF-8
-Depends: R (>= 3.5.0), ggplot2, Matrix, survey, hexbin, dplyr
-Imports: stats
+Depends: R (>= 3.5.0)
+Imports: stats, ggplot2, Matrix, survey, hexbin, dplyr
 LazyData: true
 RoxygenNote: 7.1.2
diff --git a/NAMESPACE b/NAMESPACE
index 47f87db..ed44c86 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -24,6 +24,7 @@ export(gghistweight2d_svy)
 export(gghistweight3d)
 export(gghistweight3d_svy)
 export(gghistweight_svy)
+import(Matrix)
 import(dplyr)
 import(ggplot2)
 import(hexbin)
diff --git a/R/importpackages.R b/R/importpackages.R
index d4b487d..5e877fb 100644
--- a/R/importpackages.R
+++ b/R/importpackages.R
@@ -1,2 +1,2 @@
-#' @import ggplot2 survey hexbin dplyr
+#' @import ggplot2 survey hexbin dplyr Matrix
 NULL
edd@rob:/tmp/TEMP/ggsurvey(main)$ 

我的差异如下。让我知道您是否想要一个类似的拉取请求。

编辑: 如果将 library(ggplot2) 添加到示例中,ylab() 问题就会消失。然后它仍然会故障转移 data(api),这可能需要另一个 library() 调用。