Closed mhpob closed 3 months ago
This is also an issue with data.table programming. The data.table team suggests creating these variables at the top of the function, which seems like it may be a more dplyr/data.table-agnostic fix.
https://cran.r-project.org/web/packages/data.table/vignettes/datatable-importing.html
myfun_dt <- function(){
V1 <- V2 <- V3 <- NULL
DT[, V1 := 'blah']
DT[, V2 := V1 + V3]
}
myfun_dplyr <- function(){
V1 <- V2 <- V3 <- NULL
DF |>
mutate(V1 = 'blah',
V2 = V1 + V3)
}
See example here: https://github.com/r-universe/mhpob/actions/runs/6935301215/job/18865316576#step:8:855
Looks like this comes from having bare variable names when programming with
dplyr
. Suggested fix is to use.data
to call the data.https://community.rstudio.com/t/how-to-solve-no-visible-binding-for-global-variable-note/28887/2
https://cran.r-project.org/web/packages/dplyr/vignettes/in-packages.html
https://cran.r-project.org/web/packages/dplyr/vignettes/programming.html