Englehas
Englehas

Reputation: 318

R dplyr filter for non-standard evaluation (NSE) ".dots is missing, with no default"

I am hoping someone can help determine why I receive an error message when using lazy evaluation as part of a dplyr filter_ verb. The end goal is to pass arguments by reference using a function but I have narrowed the problem down outside of a function.

library(dplyr)
library(lazyeval)
library(data.table)

data_raw_dt <- data.table(
  R_dates = seq(from = as.Date("2015/8/31"), by = "1 day", length.out = 30),
  grp_region = sample(letters[1:4], 30, replace = TRUE),
  z_valuation = rnorm(30)
)

# Create some NAs
data_raw_dt$grp_region[data_raw_dt$grp_region == "d"] <- NA

dates = "R_dates"
group = "grp_region"
column = "z_valuation"
filter_criteria = interp(~(!is.na(var)), var = as.name(group))

data_raw_dt %>%
  filter_(filter_criteria)

But this gives the following error message: "Error in lazyeval::common_env(.dots) : argument ".dots" is missing, with no default"

In this case, I am not sure how to specify .dots and when I do it asks for a list. I have checked here, here, and here and structured my code following these examples with no success.

Package version: dplyr 0.4.2 lazyeval 0.1.10 data table 1.9.4

Does anyone have any ideas? Thank you so much in advance!

Upvotes: 2

Views: 1641

Answers (1)

bramtayl
bramtayl

Reputation: 4024

Just replace with

filter_(.dots = filter_criteria)

Upvotes: 2

Related Questions