Closed entjos closed 2 years ago
Thanks for the bug report. The issue is with my poor NSE coding I think. See below extend MWE which shows that it's not detecting the value being passed into the function properly.
library(data.table)
library(disk.frame)
# Create data table and diskframe object of storm data
storms_df <- as.disk.frame(storms)
storms_dt <- as.data.table(storms)
# Create search function
grep_storm_name <- function(dfr, storm_name){
dfr[name %like% storm_name]
}
# Check function with data.table object
grep_storm_name(storms_dt, "^A")
# Check function with diskframe object
grep_storm_name(storms_df, "^A")
storms_df[name %like% "^A"]
storm_name_outside_function="^A"
storms_df[name %like% storm_name_outside_function]
grep_storm_name(storms_df, "^A")
fixed by #370
Hi there!
I recently run into an error with non-standard evaluation in a
disk.frame
call where I'm not quite sure whether it is a bug or necessary behavior. I posted my error as a question on StackOverflow last week and will just copy my post below:Problem
I'm currently trying to write a function that filters some rows of a
disk.frame
object using regular expressions. I, unfortunately, run into some issues with the evaluation of my search string in the filter function. My idea was to pass a regular expression as a string into a function argument (e.g.storm_name
) and then pass that argument into my filtering call. I used the%like%
function included in{data.table}
for filtering rows.My problem is that the storm_name object gets evaluated inside the
disk.frame
. However, since the storm_name is only included in the function environment, but not in thedisk.frame
object, I get the following error:I already tried to evaluate the
storm_name
object in the parent frame usingeval(sotm_name, env = parent.env())
, but that also didn't help. Interestingly, this problem only occurs with{disk.frame}
objects but not with{data.table}
objects.For now I found a solution using
{dplyr}
instead. However, I would be grateful for any ideas on how this problem could be solved with{data.table}
.Reproducible Example
Session Info