-
Notifications
You must be signed in to change notification settings - Fork 31
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
Replace globalvariables use with maintainable approach #165
Comments
In the spirit of closing down issues: Apparently the |
Can you give an example of how this looks like for us? |
Didn't run any tests with it yet, but I assume we'd have to replace all implicit piping by explicit So instead of If we don't want to take this step, I'd be in favour of closing this issue |
If we want to do that I would be very explicit as '$' does partial matching.
|
But do we want to do that? Doesn't feel like it adds value, is very tedious work and will probably pop up again every time one of us writes a piping statement. At least I'm fairly sure I'd forget it. Also, the issues says "maintainable" which the |
As proposed by Daniel, we should use .data to be very explicit inside all our functions which increases traceability but also ensure that the correct environment is passed throughout functions am <- blah mtcars %>% select(am) = mtcars %>% select(.data$am) |
+1 for using the am <- "mpg"
mtcars |> dplyr::select(.data$am, .env$am) |> head()
#> am mpg
#> Mazda RX4 1 21.0
#> Mazda RX4 Wag 1 21.0 Without the prefixes, the selecting is not 100% precise. This is a bit of a contrived example, but I do often find myself running into issues while writing functions with data frames having column names that match R object names outside the data frame. |
Work through the list of variables referenced in visR globalvariable to set those variables to NULL within the function call, where possible. At the moment we are using this to suppress note in R CMD check "no visible binding". Ideally, we resolve this at the function level.
See here for more details on the alternative approach STAT545-UBC/Discussion#451
The text was updated successfully, but these errors were encountered: