I have a data frame that looks like the following:
   eid    prod     dp
1    1    0 2015-12-28
2    1    1 2016-01-28
3    1    1 2016-02-28
4    2    1 2015-12-28
5    2    1 2016-01-28
6    2    1 2016-02-28
7    3    0 2015-11-28
8    3    1 2015-12-28
9    3    1 2016-01-28
10   3    0 2016-02-28
eid: alphanumeric id
prod: product holding on a certain date. So if you have added a product on a date from last month, it will still show this month, until you have opted out
dp: one row per date.
I am trying to build a flag that will tell me whether a eid added a new prod in that month or not. So I need output as followin in flg columns:
   eid    prod     dp    flg
1    1    0 2015-12-28   0
2    1    1 2016-01-28   1
3    1    1 2016-02-28   0
4    2    1 2015-12-28   0
5    2    1 2016-01-28   0
6    2    1 2016-02-28   0
7    3    0 2015-11-28   0
8    3    1 2015-12-28   1
9    3    1 2016-01-28   0
10   3    0 2016-02-28  -1
Assume that the data frame isn't sorted in any specific order
 
     
     
    