Compute statistical mode of a vector (value that occurs most frequently)
Source:R/computeMode.R
computeMode.RdWorks for integer, numeric, factor and character vectors. The implementation is currently not extremely efficient.
Arguments
- x
[
vector]
Factor, character, integer, numeric or logical vector.- ties.method
[
character(1)]
“first”, “random”, “last”: Decide which value to take in case of ties. Default is “random”.- na.rm
[
logical(1)]
IfTRUE, missing values in the data removed. ifFALSE, they are used as a separate level and this level could therefore be returned as the most frequent one. Default isTRUE.
Examples
computeMode(c(1,2,3,3))
#> [1] 3