This is apparently a simple problem but I can't figure out what function to use. Following are sample data:
gg <- data.frame(ID = c(15,15,15,16,16,16, 16,17,17,17),
ADO = c(rep("T1", 4), rep("T2", 2), rep("T3", 4)))
The "ID" is the label or category of a particular "ADO". It should be unique to each ADO. But in this case it is not:
> table(gg$ID, gg$ADO)
T1 T2 T3
15 3 0 0
16 1 2 1
17 0 0 3
I want to assign the most frequent ID to a particular ADO. So, my desired output is:
ID ADO
1 15 T1
2 15 T1
3 15 T1
4 16 T2
5 16 T2
6 16 T2
7 16 T2
8 17 T3
9 17 T3
10 17 T3
Please guide me what function can I use to fix this?