Skip to content

compute nanrange

kgryte edited this page May 12, 2015 · 1 revision

Computes the arithmetic range of an array ignoring non-numeric values.

var data = [ 2, null, 4, 2, NaN, 7, 3 ];

var range = compute.nanrange( data );
// returns [2,7]

For object arrays, provide an accessor function for accessing array values

var data = [
	[1,2],
	[2,null],
	[3,4],
	[5,2],
	[6,NaN],
	[7,7],
	[8,3]
];

function getValue( d ) {
	return d[ 1 ];
}

var range = compute.nanrange( data, getValue );
// returns [2,7]
Clone this wiki locally