>>> ggplot(myData, aes_string(x = "myX", y = "myY")) +
>>> # add my decorations
>>> theme_bw()
>>> }
>>>
>>> It is probably already the case for your function bu
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.
> >>>
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, ...) {
>&
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(
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
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
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
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
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
;
> 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
"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
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
12 matches
Mail list logo