[R-pkg-devel] Using ggplot2 within another package
Gábor Csárdi
c@@rd|@g@bor @end|ng |rom gm@||@com
Thu Apr 22 23:58:00 CEST 2021
On Thu, Apr 22, 2021 at 11:19 PM Kevin R. Coombes
<kevin.r.coombes using gmail.com> wrote:
[...]
> Instead, the vignette says you should
> importFrom("rlang", ".data")
> in your NAMESPACE, and write
> ggplot(myData, aes(x = .data$myX, y = .data$myY))
>
> And now my dinosaur question: That looks like using one non-standard
> hack to cover up the problems with another non-standard hack. Why the
> heck is that any better for the developer than writing
> ggplot(myData, aes(x = myData$myX, y = myData$myY))
Well, for one, because it does not always work, see e.g. the examples
and links here:
https://github.com/tidyverse/ggplot2/issues/2693
> or using Dirk Eddelbuettel's suggestion of calling utils::globalVariables ??
Because if you refer to a hundred different columns in your plots, then
you'll need to add all of them to globalVariables(), and this is error prone
and cumbersome to update. If you only refer a handful of columns, then sure,
this will work as well.
Gabor
[...]
More information about the R-package-devel
mailing list