Let's say I have the following dataframe:
ID <- c(15, 25, 90, 1, 23, 543)
animal <- c("fish", "dog", "fish", "cat", "dog", "fish")
df <- data.frame(ID, animal)
How could I create a third column to represent the instance (from top to bottom) that a repeat animal appears? for example, a column "Instance" in the order (1, 1, 2, 1, 2, 3)? I know I can use group_by to receive the total count, but this is not exactly what I'm after. Thanks.