modus {eatTools} | R Documentation |
Calculate the mode (most frequent value) of a variable
modus(x, randTies = FALSE)
x |
a vector |
randTies |
If |
The modus
function is designed to always return only one value for the mode of a variable. If the variable is bimodal or multimodal, the function returns either NA
(if randTies = FALSE
) or a randomly chosen value of all modes (if randTies = TRUE
).
the mode (most frequent value) of the variable
Martin Hecht
## Not run: x <- c(1, 1, 2, 2) modus(x) modus(x, randTies = TRUE) x <- c(1, NA, NA) modus(x) x <- c("x", "x", "y") modus(x) ## End(Not run)