Skip to content
Prev 6873 / 12125 Next

[R-pkg-devel] Using ggplot2 within another package

Thanks.

Obviously, long. long ago, (in a galaxy not far enough away), Paul's 
suggestion of using "aes_string" was the correct one, since "aes" uses 
non-standard evaluation. (And to quote somebody from an R fortune 
cookie, "The problem with non-standard evaluation is that it is 
non-standard.") But teh documentation at the end oft he link provided by 
Robert explivityl tells you not to do that, since "aes_string is 
deprecated".? And reading more carefully into the manual page for 
aes_string, one does indeed find the statement that the function is 
"soft deprecated". I'm not sure what that means, other than someone on 
the development team doesn't like it.

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))

or using Dirk Eddelbuettel's suggestion of calling utils::globalVariables ??

It's time to tell those kids to get off of my lawn.
 ? Kevin
On 4/22/2021 4:45 PM, Robert M. Flight wrote: