Making All Values in a Table Positive

From Q
Jump to navigation Jump to search

This code takes the first statistic on a table, and replaces the observed values with their absolute values.

var values = table.get(table.statistics[0]);
for (var r = 0; r < table.numberRows; r++)
    for (var c = 0; c < table.numberColumns; c++)
        values[r][c] = Math.abs(values[r][c]);
table.set(table.statistics[0], values);

See also