consider the following data.frame:
> head(dtrain)
content_id item_age item_ctr likes clicks no_clicks event
1 11201926 461540 0.02787456 1 24 837 0
2 11201926 462497 0.02784223 1 24 838 0
3 11201926 473215 0.02780997 1 24 839 0
4 11201926 532983 0.02777778 1 24 840 0
5 11201926 536696 0.02774566 1 24 841 0
6 11201926 545545 0.02771363 1 24 842 0
result <- split(dtrain , f = dtrain$content_id )
You can first filter your data frame using dplyr
to retain only those content groups with 1000 or more records:
temp <- dtrain
%>% group_by(content_id)
%>% filter(n() >= 1000)
and then continue as you were:
result <- split(temp, f=temp$content_id)