【发布时间】:2012-05-04 00:29:33
【问题描述】:
我只有一列包含姓名,我需要知道每个姓名在此列中出现的次数。
我可以做一个
summary(dfUL)
dfUL 是我的用户列表数据框
这将为我提供一个特定值重复次数的摘要,但它只会对前 6 个重复。我怎样才能为整个数据框做到这一点?
【问题讨论】:
标签: r statistics
我只有一列包含姓名,我需要知道每个姓名在此列中出现的次数。
我可以做一个
summary(dfUL)
dfUL 是我的用户列表数据框
这将为我提供一个特定值重复次数的摘要,但它只会对前 6 个重复。我怎样才能为整个数据框做到这一点?
【问题讨论】:
标签: r statistics
另一个可能有用的方法是match() 函数。
match(x,dfUL$somecol) #Where x is the value in somecol you are looking for
match(max(dfUL$somecol),dfUL) #Returns the row with the maximum value of somecol
【讨论】:
您是否已经尝试过table(dfUL)?
【讨论】: