I have a dataframe that looks like this
Sample_No Lab_ID
1234 2
1235 2
1236 2
2344 3
3425 4
2341 5
6756 5
...
I want to count how many times each lab_id occurs but the occurances number next to it in a new column of the dataframe to look something like the following
Sample_No Lab_ID Occurrence
1234 2 1
1235 2 2
1236 2 3
2344 3 1
3425 4 1
2341 5 1
6756 5 2
...
I can get a list of the unique values by using
I could do something like
table(df$LAB_ID)
but that produces a table summarizing the count
any help appreciated