I have an R code that I'm changing to use R's box package.
But I noticed that a function I had no longer has the dataframes columns as variables in the environment, so when I do dplyr's filter I get object 'verified' not found.
What's the easiest way to solve this? I want to load the dataframe columns as variables in the function environment.
Simplified version of my code, yes the verified column does exist
box::use(
tibble[...],
dplyr[...],
lubridate[...],
r/core[...]
)
myFunction <- function(df){
df = df %>%
filter(verified == TRUE)
return(df)
}
Because you load
r/coreafterdplyr,stats::filter()is maskingdplyr::filter(). If you loadr/corefirst, it works as intended:Alternatively, you could specify
dplyr::filter()in your function.(Finally, I’m not that familiar with box, but do you really have to explicitly load
r/coreat all?)