例子:
x <- c(1,2,2,2,3,4,5,6,7,8,9)
The following code returns the mode(s)
temp <- table(as.vector(x))
# this line creates a table called "temp". The first row of "temp" is a sorted list of all unique values in the vector-or-matrix "x". The second row in "temp" counts how many occurrences of each value. So there's be "1" under the values 1,3,4,5,6,7,8 & 9. And a "3" under the value 2.
names(temp)[temp == max(temp)]
来源:
http://www.cazaar.com/ta/econ113/mode-code-for-r


雷达卡




京公网安备 11010802022788号







