Getting unique rows of a table and their numbers

前端 未结 3 791
夕颜
夕颜 2020-12-12 01:44

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

3条回答
  •  我在风中等你
    2020-12-12 02:11

    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
    

提交回复
热议问题