imaxLast

Syntax

imaxLast(X)

Details

Returns the position of the element with the largest value in X. If there are multiple elements with the identical largest value, return the position of the first element from the right. Same as other aggregate functions, null values are ignored.

The indexing starts from 0.

If the input is an empty vector, -1 is returned.

Parameters

X is a scalar/vector/matrix/table.

Returns

  • If X is a scalar or vector, return an INT scalar, indicating the position of the element with the largest value.
  • If X is a matrix, return a vector containing the position of the element with the largest value in each column.

  • If X is a table, return a table. Each column of the table contains the position of the element with the largest value in the corresponding column of X.

Examples

x = 1.2 2 NULL -1 6 -1
imaxLast(x);
// output: 4

m=matrix(3 2 4 4 2, 1 4 2 4 3);
imaxLast(m) 
// output: [3,3]

t=table(3 3 2 as c1, 1 4 4 as c2)
imaxLast(t)
/* output:
c1	c2
0	2
*/

Related function: imax