med
Syntax
med(X)
Arguments
X is a scalar/vector/matrix.
Details
If X is a vector, return the median of all the elements in X.
If X is a matrix, calculate the median of each column of X and return a vector.
As with all aggregate functions, NULL values are not included in the calculation.
Please note that the data type of the result is always DOUBLE.
Examples
$ x=3 6 1 5 9;
$ med x;
5
$ m=matrix(1 2 10, 4 5 NULL);
$ m;
#0 |
#1 |
---|---|
1 |
4 |
2 |
5 |
10 |
$ med m;
[2,4.5]