I want to know the way of counting the number of observations using R.
For example, let's say I have a data df
as follows:
df <- data.frame(id = c(1,1,1,2,2,2,2,3,3,5,5,5,9,9))
Even though the biggest number of id
is 9, there are only 5 numbers: 1,2,3,5,and 9. So there are only 5 numbers in id
. I want to count how many numbers exist in id
like this.