함수 mode()

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

1 개요

함수 mode()

2 R

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"

3 같이 보기

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