A .ranks( x )

Read(327) Label: get, ranking,

Description:

Get the rankings of members of sequence A.(x).

Syntax:

A.ranks(x)

Equivalent to A. (x).ranks()

Note:

The function computes expression x over each member of sequence A to return the rankings of members of sequence A.(x), which by default is sorted in ascending order.

Options:

@z

Return a ranking according to members sorted in descending order. Here “z” is in lowercase.

@i

Deduplicate sequence A.(x) before getting the rankings.

@s

Perform average operation for each of the duplicate ranking and return the result, which could contain non-integers. Take the sequence [3,2,6,6,9] for example, a default ranking is [2,1,3,3,5]; but with @s option, the ranking becomes [2.0,1.0,(3+4)/2,(3+4)/2,5.0] after we get averages for the two duplicates.

Parameters:

x

An expression according to which sequence A is computed

A

A sequence

Return value:

An integer sequence made up of rankings of members of sequence A.(x).

Example:

 

A

 

1

=demo.query("select * from SCORES where SUBJECT='English'")

 

2

=A1.ranks(SCORE)

[7,9,13,1,17,5,13,19,3,25,11,21,23,25,7,9,13,1,17,5,13,19,3,25,11,21,23,25];Rank members in ascending order

3

=A1.ranks@z(SCORE)

[21,19,13,27,11,23,13,9,25,1,17,7,5,1,21,19,13,27,11,23,13,9,25,1,17,7,5,1];Rank members in descending order

4

=A1.ranks@i(SCORE)

[4,5,7,1,8,3,7,9,2,12,6,10,11,12,4,5,7,1,8,3,7,9,2,12,6,10,11,12]; rankings with duplicates removed

5

=A1.(SCORE).ranks()

Same requirement as that in A2

6

=A1.ranks@s(SCORE)

[21.0,10.0,20.0,2.0,6.0,22.0,26.0,8.0,14.0,9.0,12.0,5.0,15.0,19.0,4.0,11.0,13.0,1.0,28.0,24.0,25.0,16.0,17.0,23.0,27.0,7.0,18.0,3.0]; get averages for duplicate rankings and then return the final result

Related functions:

A.ranks()