mode
Syntax
mode(X)
Arguments
X is a scalar/vector/matrix.
Details
If X is a vector, calculate the most frequently occurring value in X.
If X is a matrix, calculate the most frequently occurring value in each column of X and return a vector.
As with all aggregate functions, NULL values are not included in the calculation.
Examples
$ mode 2;
2
$ mode 1 3 3 3 4 5 5;
3
$ mode `test;
test
$ m=matrix(1 1 2 2 2 3, 4 4 5 6 6 6);
$ m;
#0 |
#1 |
---|---|
1 |
4 |
1 |
4 |
2 |
5 |
2 |
6 |
2 |
6 |
3 |
6 |
$ mode m;
[2,6]