是否有一個內(nèi)置的功能來查找模式?在R,mean()和median()都是標準的函數(shù),可以做你期望的事情。mode()告訴您對象的內(nèi)部存儲模式,而不是其參數(shù)中發(fā)生最多的值。但是,是否有一個標準庫函數(shù)來實現(xiàn)向量(或列表)的統(tǒng)計模式?
3 回答

智慧大石
TA貢獻1946條經(jīng)驗 獲得超3個贊
Mode <- function(x) { ux <- unique(x) ux[which.max(tabulate(match(x, ux)))]}
which.max
Modes <- function(x) { ux <- unique(x) tab <- tabulate(match(x, ux)) ux[tab == max(tab)]}

泛舟湖上清波郎朗
TA貢獻1818條經(jīng)驗 獲得超3個贊
modeest
mySamples <- c(19, 4, 5, 7, 29, 19, 29, 13, 25, 19)library(modeest)mlv(mySamples, method = "mfv")Mode (most likely value): 19 Bickel's modal skewness: -0.1 Call: mlv.default(x = mySamples, method = "mfv")

UYOU
TA貢獻1878條經(jīng)驗 獲得超4個贊
names(sort(-table(x)))[1]
- 3 回答
- 0 關(guān)注
- 674 瀏覽
添加回答
舉報
0/150
提交
取消