全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
3554 4
2014-06-18
例子:
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

二维码

扫码加我 拉你入群

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

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

全部回复
2014-6-18 15:30:00
路过。学习下
二维码

扫码加我 拉你入群

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

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

2014-6-18 21:48:37
as.numeric(names(table(x))[table(x)==max(table(x))])
二维码

扫码加我 拉你入群

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

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

2014-6-18 21:51:16
library(prettyR)
Mode(x)
二维码

扫码加我 拉你入群

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

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

2014-6-19 05:45:34
提示: 作者被禁止或删除 内容自动屏蔽
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群