[R-pkg-devel] Using ggplot2 within another package
Kevin R. Coombes
kev|n@r@coombe@ @end|ng |rom gm@||@com
Thu Apr 22 22:28:55 CEST 2021
Hi,
I'm trying to help clean up an R package for someone else to submit to
CRAN. He has used ggplot2 to implement a plotting function for the kinds
of things that his packages generates. His plotting routine basically
looks like (after changing names to protect the innocent):
myPlot <- fucntion(myData, ...) {
# get ready
ggplot(myData, aes(x = myX, y = myY)) +
# add my decorations
theme_bw()
}
Of course, "R CMD check --as-cran" complains that there is no global
binding for "myX" or "myY" since they are columns defined in the
data.frame "myData".
What is the best way to work around this issue?
Of course, dinosaurs like myself might be tempted to suggest just using
plain old "plot", so I don't need to see those suggestions.
Do I just ignore the usual ggplot conventions and write "myData$myX"
inside "aes" in order to appease the CRAN checker? Or is there some
tidy-er way to solve this problem?
Thanks,
Kevin
More information about the R-package-devel
mailing list