My data looks like:
ID category
101 A
101 B
101 C
102 A
103 B
103 C
I would like the result like:
ID category Count
101 A 3
101 B 3
101 C 3
102 A 1
103 B 2
103 C 2
I have tried something like:
data<-sqldf("select *,count(ID) as count from data group by ID")
It is showing the output as:
ID category count
101 C 3
102 A 1
103 C 2
An option using
data.table
Or using
dplyr
Or using
base R