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

2021-04-24 Thread Ben Bolker
  >>>     ggplot(myData, aes_string(x = "myX", y = "myY")) +     >>>        # add my decorations     >>>        theme_bw()     >>> }     >>>     >>> It is probably already the case for your function bu

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

2021-04-24 Thread Bill Dunlap
vin, > >>> > >>> 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. > >>>

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

2021-04-24 Thread Martin Maechler
tring()' 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, ...) { >&

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

2021-04-23 Thread Tiago Olivoto
Hi everyone, One suggestion would be import ggplot2 and using tidy eval operators to create a function. One simple reproducible example would be library(ggplot2) my_hist <- function(df, var){ ggplot(df, aes({{var}})) + geom_histogram() } df <- data.frame(my_var = rnorm(400, 10, 2)) my_hist(

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

2021-04-23 Thread Mike Collyer
Hi Kevin, I recently developed a plot function in a package that used ggplot and ran into the same problem. I overcame the problem with a first line of (useless) code as myX <- myY <- NULL I found the solution inelegant but it worked. cheers! Mike > On Apr 22, 2021, at 4:28 PM, Kevin R. Coom

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
n but you need to include #' @import ggplot2 in your function preamble (if I am not wrong). Kind regards Paul ----- Mail original - De: "Kevin R. Coombes" mailto:kevin.r.coom...@gmail.com>> À: "r-package-devel" mailto:r-packa

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

2021-04-22 Thread Kevin R. Coombes
ed to > include #' @import ggplot2 in your function preamble (if I am not > wrong). > > Kind regards > Paul > > - Mail original - > De: "Kevin R. Coombes" <mailto:kevin.r.coom...@gmail.com>> > À: "r-package-de

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
; > Kind regards > Paul > > ----- Mail original - > De: "Kevin R. Coombes" > À: "r-package-devel" > Envoyé: Jeudi 22 Avril 2021 22:28:55 > Objet: [R-pkg-devel] Using ggplot2 within another package > > Hi, > > I'm trying to help clean u

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

2021-04-22 Thread Paul SAVARY
"Kevin R. Coombes" À: "r-package-devel" Envoyé: Jeudi 22 Avril 2021 22:28:55 Objet: [R-pkg-devel] Using ggplot2 within another package 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 f

[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