I am trying to filter out Client Id's from a data frame that appear within the first three months of my dataset, but DO NOT appear after the end of the first three months, leaving me with the Client Id's that appear in both before and after the first three months. I have included some code to create a mock dataset for illustration:-
ClientId<-c('hgjj156','jksu990','ddks989','fghs676','shjk992','hddq141','huui667','kili1772','djjp8998','hdyy1122','fghs676','shjk992','hgjj156','jksu990')
DateStamp<-c('01-01-2015', '01-01-2015', '03-01-2015', '10-01-2015', '22-01-2015', '29-01-2015','05-02-2015','11-02-2015', '19-02-2015', '17-03-2015', '02-04-2015', '06-04-2015', '08-04-2015', '09-04-2015')
df<-cbind(ClientId, DateStamp)
df
Which should give you this:-
ClientId DateStamp
"hgjj156" "01-01-2015"
"jksu990" "01-01-2015"
"ddks989" "03-01-2015"
"fghs676" "10-01-2015"
"shjk992" "22-01-2015"
"hddq141" "29-01-2015"
"huui667" "05-02-2015"
"kili1772" "11-02-2015"
"djjp8998" "19-02-2015"
"hdyy1122" "17-03-2015"
"fghs676" "02-04-2015"
"shjk992" "06-04-2015"
"hgjj156" "08-04-2015"
"jksu990" "09-04-2015"
The idea is that I would be left with the following ID's:-
ClientId DateStamp
"hgjj156" "01-01-2015"
"jksu990" "01-01-2015"
"fghs676" "10-01-2015"
"shjk992" "22-01-2015"
"fghs676" "02-04-2015"
"shjk992" "06-04-2015"
"hgjj156" "08-04-2015"
"jksu990" "09-04-2015"
Is there any idea as to how I would achieve this? I had looked at dplyr and data.table solutions but so far I haven't found which ones would be the most appropriate.