I have a dataframe:
id y z
oX 79 100
oX 23 46
oX 10 29
uM 12 90
uT 43 50
uT 13 99
I would like to keeep unique rows based on
this will do what you want :
> as.data.frame(table(a$id))
Var1 Freq
1 oX 3
2 uM 1
3 uT 2
Just wanted to post another alternative, consider data.table
> library(data.table)
> data.table(mydf)[,.N, by="id"]
id N
1: oX 3
2: uM 1
3: uT 2
Assuming your data.frame
is called "mydf", table
should work just fine:
table(mydf$id)
#
# oX uM uT
# 3 1 2