"R 최빈값 getmode()"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>))
10번째 줄: 10번째 줄:
print( getmode( v ) )
print( getmode( v ) )
# 2
# 2
</source>
</syntaxhighlight>
<source lang='r'>
<source lang='r'>
getmode <- function(v) {
getmode <- function(v) {
19번째 줄: 19번째 줄:
print( getmode( charv ) )
print( getmode( charv ) )
# "it"
# "it"
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==

2020년 11월 2일 (월) 00:42 판

1 개요

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( v ) )

  1. 2

</syntaxhighlight> <source lang='r'> getmode <- function(v) {

 uniqv <- unique(v)
 uniqv[which.max(tabulate(match(v, uniqv)))]

} charv <- c("o","it","the","it","it") print( getmode( charv ) )

  1. "it"

</syntaxhighlight>

2 같이 보기

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