Full disclosure: this issue is duplicated on the ggplot2 google group
I'm developing a package that makes heavy use of ggplot2
. I've created my own geom—geom_rug_alt
—as a way of putting rug fringes on the top/right of the plot instead of the default locations.
My problem is that when geom_rug_alt()
is defined and called within a single script, it seems to plot just fine. (Please try it yourself to verify that.) But, in my package geom_rug_alt()
is defined in one file (CommonFunctions.R
) and called in another (the Residuals()
function of larger function foo.R
). When I call foo.R
on something, I get this error:
Error in geom_rug_alt(aes(x = NULL, y = within.group.residuals, color = factor(within.1.sd.of.the.mean.of.all.residuals)), :
object 'GeomRugAlt' not found
Now, I've done a couple of things (suggested by Hadley in this thread) to try to make sure that geom_rug_alt()
should work properly within the package:
I define
GeomRugAlt
as aproto
object in a file essentially calledCommonFunctions.R
within my package.CommonFunctions.R
contains lines 3-42 of my example script.In
CommonFunctions.R
, I was sure to include thebuild_accessor()
line forgeom_rug_alt
(line 42 in my example script) after the definition ofGeomRugAlt
In the package
DESCRIPTION
file, I have acollate:
line whereCommonFunctions.R
appears first- In the package
DESCRIPTION
file, I have aLazyLoad: false
line - In
CommonFunctions.R
, I included arequire(ggplot2)
call before definingGeomRugAlt
as aproto
object. - In
foo.R
, I included arequire(ggplot2)
call before callinggeom_rug_alt()
withinResiduals()
.
I'm not sure what else I'm missing. Given that my example script runs just fine, I suspect the issue isn't that my geom doesn't work, but that I'm doing something wrong as part of the package development process.
Sorry for duplicating the issue, but I can't seem to find a thorough solution to the problem :-(
Put
export(GeomRugAlt)
in theNAMESPACE
file.