Dynamic filter in R

I have a data sale and other dataset promotion. the promotion dataset contains information about when the sales promotion occurred. Now I need to identify the sales data that is associated with a specific ad.

I extracted the first line and created a filter

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

      

tried to

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

      

and I am getting the following error:

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

      

How to do it.

+3


source to share


1 answer


Try filter_(sales, promo.filter)




From a custom score vignette:

Every function in dplyr using NSE also has a version using SE. Theres a consistent naming scheme: SE is an NSE name with an _

on end. For example, SE version summarise()

equals summarise_()

, SE version arrange()

equals arrange_()

. These functions work very similarly to their NSE cousins, but the input must be "quoted"

+3


source







All Articles