data array
options object
array containing the computed ranks for the elements of x
var arr = [ 1.1, 2.0, 3.5, 0.0, 2.4 ];
var out = ranks( arr );
// returns [ 2, 3, 5, 1, 4 ]
// Ties are averaged:
arr = [ 2, 2, 1, 4, 3 ];
out = ranks( arr );
// returns [ 2.5, 2.5, 1, 5, 4 ]
// Missing values are placed last:
arr = [ null, 2, 2, 1, 4, 3, NaN, NaN ];
out = ranks( arr );
// returns [ 6, 2.5, 2.5, 1, 5, 4, 7 ,8 ]
Computes the sample ranks for the values of an array-like object.
Notes
array
are different, the ranks are uniquely determined. When there are equal elements (called ties), themethod
option determines how they are handled. The default,'average'
, replaces the ranks of the ties by their mean. Other possible options are'min'
and'max'
, which replace the ranks of the ties by their minimum and maximum, respectively.'dense'
works like'min'
, with the difference that the next highest element after a tie is assigned the next smallest integer. Finally,ordinal
gives each element inarr
a distinct rank, according to the position they appear in.missing
option is used to specify how to handle missing data. By default,NaN
ornull
are treated as missing values.'last'
specifies that missing values are placed last,'first'
that the are assigned the lowest ranks and'remove'
means that they are removed from the array before the ranks are calculated.must provide valid options