I have a data frame that looks like this:
id score 1 15 1 18 1 16 2 10 2 9 3 8 3 47 3 21
I would like to define a way to indicate the first occurrence of an identifier - similar to the first. And last. in SAS. I tried a duplicate function, but I need to actually add the βflagβ column to my data frame, since I run it through the loop later. I would like to get something like this:
id score first_ind 1 15 1 1 18 0 1 16 0 2 10 1 2 9 0 3 8 1 3 47 0 3 21 0
r
davids12
source share