R 최빈값 getmode()

Jmnote (토론 | 기여)님의 2017년 12월 19일 (화) 00:16 판 (새 문서: ==개요== ;R mode() ;R getmode() <source lang='r'> getmode <- function(v) { uniqv <- unique(v) uniqv[which.max(tabulate(match(v, uniqv)))] } v <- c(2,1,2,3,1,2) print( getmode(...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

R mode()
R getmode()
getmode <- function(v) {
  uniqv <- unique(v)
  uniqv[which.max(tabulate(match(v, uniqv)))]
}
v <- c(2,1,2,3,1,2)
print( getmode( v ) )
# 2
getmode <- function(v) {
  uniqv <- unique(v)
  uniqv[which.max(tabulate(match(v, uniqv)))]
}
charv <- c("o","it","the","it","it")
print( getmode( charv ) )
# "it"

2 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}