-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standard evaluation functions #79
Comments
Hi, Thomas, Are you talking about making the kind of syntax below works?
If that is the case I can help. |
Yes, that's exactly what I had in mind. {dplyr} used to have functions that accept strings rather than symbols, i.e. |
Nice! So, what do you think it is a better approach? But, it is also possible to make an auto evaluation function, like: auto_evaluate <- function(x) {
if(is.character(substitute(x))) {
x <- dplyr::sym(x)
} else {
x <- rlang::enquo(x)
}
return(x)
} Which would replace in {ggcharts} functions: x <- rlang::enquo(x)
y <- rlang::enquo(y)
facet <- rlang::enquo(facet) for x <- auto_evaluate(x)
y <- auto_evaluate(y)
facet <- auto_evaluate(facet) Which one do you prefer? Do you know another approaches? I really would like to contribute, but sometimes I'm not very confident about my knowledge in R and good practices. Thanks! |
I thought about something like the
pkg <- "dplyr"
library(pkg)
library(pkg, character.only = TRUE)
|
@nathaneastwood How would you handle this? |
So I actually use a function in {poorman} for this type of thing: https://github.com/nathaneastwood/poorman/blob/master/R/utils.R#L31 |
By the way, is there no rlang solution to this? Since ggplot2 already imports rlang, I would be tempted to find a solution there, the dependency is already there. |
By the way, have you considered the |
Yes, there are some possible solutions in rlang. I was considering create some function to convert SE to NSE input but it sounds pretty unsafe. What do you think about functions like I thought about it a lot and I am very convinced that it would be better to have a function for NSE and another for SE. |
I don’t think it’s a good idea to use an argument to change the behaviour of another argument because it makes function calls harder to understand. Don't you? What do you think about having a function to SE and another to NSE? Make something like |
I think having two separate functions, one with standard evaluation semantics and one with non-standard one is the way to go as it's completely transparent what is going on 👍 |
All functions currently use non-standard evaluation which is great for interactive use but IMO clumsy to program with. Having functions that accepts strings as arguments could come in very handy in
{shiny}
apps.The text was updated successfully, but these errors were encountered: