Making All Values in a Table Positive
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
- User Input for Rules for technical information on Rules.
- Rule Online Library for other examples of Rules.
- Table JavaScript and Plot JavaScript for the JavaScript that is used to write custom rules.
- JavaScript for information about the JavaScript programming language.