R中的动态过滤器

dynamic filter in R

我有一个数据集销售和另一个数据集促销。 促销数据集包含促销发生时间的详细信息。现在,我需要确定与特定促销相关的销售数据。

我提取了第一行并创建了一个过滤器

promo.filter="product.no==1100001369 & (customer.state==TN | customer.state==AP) & (cgrp==12 | cgrp==13)"

尝试过

promo.sales<-filter(sales, promo.filter)

我收到以下错误

Error: filter condition does not evaluate to a logical vector. 

如何完成此操作。

尝试filter_(sales, promo.filter)


来自 non-standard evaluation 小插图:

Every function in dplyr that uses NSE also has a version that uses SE. There’s a consistent naming scheme: the SE is the NSE name with _ on the end. For example, the SE version of summarise() is summarise_(), the SE version of arrange() is arrange_(). These functions work very similarly to their NSE cousins, but the inputs must be “quoted”