I'm dealing with a dataset with has data at a day level (one row for one day) - with data for a product (that is being advertised) on whether it is being seen by the user or if an action is being taken.
Before ruing my analysis on this data set in R - i'm want to filter the data in such a way i filter out all the days where the difference of number of times product is seen and number of times the action is being taken is 2 and views are 3. I was able to do this via an SQL statement in R - First i filter out the required days using the sqldf package like:
filterd_days = sqldf(select day, count(views) as seen, count(action)
as actions from subset_data group by day
having (count(views) - count(action) = 2) and count(views) = 3)
I then join this dataset (o/p of the SQL) with the original one to filter the original data set with the required dates.
data_new = data[data$day %in% filter_days$day,]
But this is taking a close to 5 minutes for each dataset to execute and as this needs to run every day wondering if there's a faster way to execute this operation and get the same o/p.
