2

I've written a package in which the following is in the imports:

Rcpp (>= 0.11.0),ggplot2,grid,gridExtra,png,methods,ape,Biostrings

I have read this artcle about how R searches: how R searches, and I figured basically unless there's a very good reason not to - it's is safer to import packages that mine depends on, and not to put them in the dependencies.

However I'm seeing the error whe I use my package:

could not find function "rasterGrob"

My suspicion is that ggplot Depends on Grid, so I have to make my package Depend on grid too, so as the grid is attached and so 'package:grid' will be seen when executing search().

A). Is my understanding correct? and B). So do I simply have to also Depend on Grid, or is it a better idea to Depend on ggplot2 also?

Thanks, Ben.

SJWard
  • 3,629
  • 5
  • 39
  • 54
  • What code are you running that triggers this error? Are you calling `rasterGrob` directly in your code? – MrFlick Feb 03 '15 at 18:36
  • 1
    You may need to attach the grid NAMESPACE. I don't think that either lattice or ggplot2 actually load pkg:grid. The rasterGrob-function may not be exported. – IRTFM Feb 03 '15 at 19:03
  • I do call rasterGrob in my package, yes. – SJWard Feb 03 '15 at 20:11
  • 1
    What version of `ggplot2` do you have installed? The latest on CRAN seems to indicate the `ggplot2` imports `grid`. From the discussion of [the differences between imports/depends](http://stackoverflow.com/questions/8637993/better-explanation-of-when-to-use-imports-depends) it seems like your code should work. A clear, reproducible example would be helpful here. – MrFlick Feb 04 '15 at 06:33
  • This error has dissapeared since I updated ggplot2, thanks! I do have another problem, but I shall make that a separate question. – SJWard Feb 05 '15 at 17:43
  • the rasterGrob depends on grid, so IRTFM is correct, you need to load that library explicitly. – EngrStudent Sep 28 '20 at 18:18

0 Answers0