Create index column based on existent groups of rows (with duplicates)
问题 The question is similar to (Update) Add index column to data.frame based on two columns Here my example data.frame: df = read.table(text = 'ID Day Count Count_group 77661 14498 4 5 76552 14498 4 5 37008 14498 4 5 34008 14498 4 5 30004 14497 1 5 30004 14497 1 4 28047 14496 3 4 28049 14496 3 4 29003 14496 3 4 69012 14468 1 4 69007 14467 3 4 69012 14467 3 4 69020 14467 3 4 42003 13896 2 4 42011 13896 2 4 22001 13895 2 4 23007 13895 2 4 28047 14496 3 3 28049 14496 3 3 29003 14496 3 3 69007 14467