i have a data frame
> data
session id item id
1 1
1 1
1 1
2 1
2 2
3 1
3 0
3 3
3 2
and i want to calculate avg of each session id like this uniqueitemsinsession/totalitems= ans (1/3=0.333)and get result like this
> result
session id avg
1 0.333
2 1.000
3 1.000
how can i do this??