Hi everyone,
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 a proto object in a file essentially called CommonFunctions.R within my package. CommonFunctions.R contains lines 3-42 of my example script.
- In CommonFunctions.R, I was sure to include the build_accessor() line for geom_rug_alt (line 42 in my example script) after the definition of GeomRugAlt
- In the package DESCRIPTION file, I have a "collate:" line where CommonFunctions.R appears first
- In the package DESCRIPTION file, I have a "LazyLoad: false" line
- In CommonFunctions.R, I included a require("ggplot2") call before defining GeomRugAlt as a proto object.
- In foo.R, I included a require("ggplot2") call before calling geom_rug_alt() within Residuals().
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.
- Brian