I have a dataset, which i define for example like this:
type <- c(1,1,1,2,2,2,2,2,3,3,4,4,5)
val <- c(4,1,1,2,8,2,3,2,3,3,4,4,5)
tdt <- data.frame(plu, occur)
So it looks like this:
type val
1 4
1 1
1 1
2 2
2 8
2 2
2 3
2 2
3 3
3 3
4 4
4 4
5 5
5 7
I want to find how many unique vals each type gets (turnover). So desired result is:
type turnover
1 2
2 3
3 1
4 1
5 2
How could i get it? How this function should look like? I know how to count occurrences of each type, but not with each unique val