楼主: coral033
3553 4

[程序分享] 如何计算众数 [推广有奖]

  • 1关注
  • 17粉丝

VIP

古墓派预测分支

已卖:3260份资源

副教授

71%

还不是VIP/贵宾

-

威望
1
论坛币
114832 个
通用积分
157.6483
学术水平
58 点
热心指数
101 点
信用等级
49 点
经验
3219 点
帖子
522
精华
1
在线时间
695 小时
注册时间
2007-3-10
最后登录
2023-12-12

楼主
coral033 在职认证  发表于 2014-6-18 15:29:20 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
例子:
x <- c(1,2,2,2,3,4,5,6,7,8,9)

The following code returns the mode(s)
temp <- table(as.vector(x))
# this line creates a table called "temp". The first row of "temp" is a sorted list of all unique values in the vector-or-matrix "x". The second row in "temp" counts how many occurrences of each value. So there's be "1"   under the values 1,3,4,5,6,7,8 & 9. And a "3" under the value 2.
names(temp)[temp == max(temp)]


来源:
http://www.cazaar.com/ta/econ113/mode-code-for-r

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:如何

本帖被以下文库推荐

Out of difficulties, makes miracles.

沙发
zhonghl82 发表于 2014-6-18 15:30:00
路过。学习下

藤椅
dxystata 发表于 2014-6-18 21:48:37
as.numeric(names(table(x))[table(x)==max(table(x))])

板凳
dxystata 发表于 2014-6-18 21:51:16
library(prettyR)
Mode(x)

报纸
Nicolle 学生认证  发表于 2014-6-19 05:45:34
提示: 作者被禁止或删除 内容自动屏蔽

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-31 08:59