mode_stat | R Documentation |
Calculates the mode of x.
mode_stat(x)
x |
input vector |
In case of ties, or if length(x) == 1
, will return the first value.
The standard caveats apply to floats; see examples.
The most frequent value in x, or see details for exception cases.
Will throw a warning if length(unique(x) == length(x))
.
Credit: http://stackoverflow.com/questions/2547402/is-there-a-built-in-function-for-finding-the-mode
mode_stat(sample(1:10, 100, replace = TRUE)) mode_stat(sample(LETTERS[1:3], 20, replace = TRUE)) ## Not run: set.seed(1) x <- rnorm(100) x[1] == mode_stat(x) x <- signif(x, 2) x[1] == mode_stat(x) #better, but note about ties applies ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.