mode_average | R Documentation |
Function to calculate mode (the value that appears most often) of a vector.
mode_average(x, na.rm = FALSE)
x |
Input vector. |
na.rm |
Should |
Vector with a length of 1
.
Ken Williams.
stackoverflow,
mean
, median
# Calculate the mode of integers
mode_average(c(1L, 2L, 3L, 3L))
# Calculate the mode of a numeric vector
mode_average(c(5, 6, 6, 500000))
# Will return the first element when one or two elements are supplied
mode_average(c(5, 1))
mode_average(c("hail", "rain"))
# Will also work with character and factor vectors
mode_average(c("rain", "hail", "sunshine", "rain"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.