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

I am developing my first R package. It is an extension of ggplot2 to work with survey data and the survey package. It depends on ggplot2, dplyr, hexbin, and survey.

When I run a check on a machine with the dependencies, the check succeeds. However, it is failing checks on CRAN, and when I run it on R Hub I get the following error: Error : package ‘Matrix’ required by ‘survey’ could not be found.

I tried adding Matrix to depends but it still does not work.

This is my description:

Package: ggsurvey
Type: Package
Title: Simplifying `ggplot2` for Survey Data
Version: 1.0.0
Author: Brittany Alexander
Maintainer: Brittany Alexander <[email protected]>
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

And my namespace:

# 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)

The full github repository is here: https://github.com/balexanderstats/ggsurvey Any ideas on what is going wrong?

Upvotes: 0

Views: 1885

Answers (1)

Dirk is no longer here
Dirk is no longer here

Reputation: 368241

Ok, I clone your repo (thanks for providing a link!) and I see

   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.

and that is just a 'Note' and not an error. I see that you use Depends:, these days were we have NAMESPACE an Imports: is preferable. And as the message say you seem to have an import for each of these packages but not Matrix. Easy to add though on the same line in R/importpackages.R. With that I check fine here (apart from an error in examples: could not find function "ylab" which I will leave for you.

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 <[email protected]>
 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)$ 

My diff is below. Let me know if you would a like pull request with it.

Edit: And the ylab() issue goes away if you add library(ggplot2) to your examples. It then still fails over data(api) which may need another library() call.

Upvotes: 1

Related Questions