Description Usage Arguments Value TODO Examples
Return most frequent level of factor (majority voting)
1 | majority(x)
|
x |
a factor |
factor of length 1 with the same levels as x
If the majority voting is ambiguous: random choice or preferred level.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | x1 = c(2,3,1,1,1,3,3,2,2,1)
f1 = factor(x1, levels = c(1, 2, 3), labels = c("red", "blue", "green"))
f1
majority(f1)
x2 = c(2,3,1,1,1,3,3,2,2,1,2)
f2 = factor(x2, levels = c(1, 2, 3), labels = c("red", "blue", "green"))
f2
majority(f2)
x3 = c(3,3,3,1,1,1,1,5,5,3,1)
o3 = ordered(x2, levels = c(1, 3, 5), labels = c("Low", "Medium", "High"))
o3
majority(o3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.