0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rでモードを表すテンプレート

Posted at
tags: rBasicLearning

1. テンプレート

mode <- function(a){
  h1 <- hist(a,
             breaks = max(a)-1)
  Mode <- which.max(h1$counts)
  
  return(c(Mode))
}

2. 具体例

使うデータ

data <- c(1, 1, 1, 1, 2, 3, 4, 5, 16, 20)

出力

mode(data)
> mode(data)
[1] 1
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?