majority {knnflex} | R Documentation |
A function which determines the majority class of a vector (treated as factor).
majority(x)
x |
a one dimensional vector |
This function treats the input vector as a factor and determines which level (class) of the factor is present most often. If two or more levels tie for majority then a random selection is made among the ties.
The factor level which occurs most often in x.
Atina Dunlap Brooks
x <- sample( c("a","b","c","d","e"), 10, replace=TRUE ) majority(x)