Description Usage Arguments Details Value Examples
Get the modus of a variable, i. e. the value that is most frequent in an variable (can be numeric and character)
1 | modus(variable, useNA = "no", equal.dist = 99)
|
variable |
The variable containing |
useNA |
Should NAs be used? Will be passed on to |
equal.dist |
If all entries are equally often, this value will be returned as output. Default is to 99. |
If two (not all) values are equally often in the variable, the first value of these will be returned. A message is issued.
The modus will be returned.
1 2 3 4 5 6 7 8 9 10 11 12 | letter_samp <- sample(letters, 50, TRUE)
modus(letter_samp)
##
set.seed(9)
m <- matrix(sample(1:5, 30, replace=TRUE), 10, 3, byrow=TRUE)
m[c(23, 12)] <- NA
m[c(4)] <- 1 # no variance
data <- as.data.frame(m)
apply(data, 1, modus)
##
# message, since 2 and 3 are equally often.
modus(c(2, 2, 2, 3, 3, 3, 4, 4))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.