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

2021-04-22 Thread Gábor Csárdi
On Thu, Apr 22, 2021 at 11:19 PM Kevin R. Coombes 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

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

2021-04-22 Thread Ben Bolker
For some reason that I don't remember, an R core member once told me that they prefer x <- y <- NULL to utils::globalVariables(c("x","y")) - although I have also encountered problems with that strategy in edge cases. Here's an example from StackOverflow from today where for some reason I do

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

2021-04-22 Thread Kevin R. Coombes
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.")

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

2021-04-22 Thread Dirk Eddelbuettel
On 22 April 2021 at 16:28, Kevin R. Coombes wrote: | 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 cha

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

2021-04-22 Thread Robert M. Flight
Kevin, This vignette from ggplot2 itself gives the "officially recommended" ways to avoid the warnings from R CMD check https://ggplot2.tidyverse.org/articles/ggplot2-in-packages.html Cheers, -Robert On Thu, Apr 22, 2021 at 4:39 PM Paul SAVARY wrote: > Hi Kevin, > > I was faced to the same p

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

2021-04-22 Thread Paul SAVARY
Hi Kevin, I was faced to the same problem and I used 'aes_string()' instead of 'aes()'. You can then just write the name of the columns containing the data to plot as character strings. Example: myPlot <- function(myData, ...) { # get ready ggplot(myData, aes_string(x = "myX", y = "myY

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

2021-04-22 Thread Kevin R. Coombes
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 <- fucnt