It seems that what we need is really ignoreLocalVariables() rather
than globalVariables() ... ?
On 4/24/21 4:56 PM, Bill Dunlap wrote:
Has there been any thought given to an alternative to globalVariables
that would flag certain arguments to certain functions as being
evaluated in a non-stan
Has there been any thought given to an alternative to globalVariables that
would flag certain arguments to certain functions as being evaluated in a
non-standard way. E.g.,
usesNSE(FUN="with.default", ARGUMENTS="expr")
usesNSE(FUN="lm", ARGUMENTS=c("weights","subset","offset"))
usesNSE
> Ben Bolker
> on Thu, 22 Apr 2021 17:27:49 -0400 writes:
> 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")) -
That could have been me. Even though I think I still have some
globalV
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
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
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.")
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
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
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
11 matches
Mail list logo