Adding Sample Size to the Column Labels

From Q
Jump to navigation Jump to search

Adds the Column n values from the Statistics - Below to the bottom of the column headers in the table. This does not apply for tables that do not have the Statistics - Below available.

var do_java; // Prevent an error when no below_table exists
try {
    do_java = below_table.availableStatistics.indexOf('Column n') != -1;
} catch (e) {
    do_java = false;
}
if (table.numberColumns > 1 && do_java) {// If this table has the 'Column n' statistic
    var column_ns = below_table.get('Column n');// Get the column n values
    if (column_ns.length == 1)
        column_ns = column_ns[0];
    var column_labels = table.columnLabels;// Get the standard column labels.
    for (var column = 0; column < table.numberColumns; column++) {// For each column...
        // Adjust the label to include the column name and column n, on new lines.
        column_labels[column] = column_labels[column] + '\r\n' + 'n = ' + column_ns[column];
    }
    // Set the adjusted column labels.
    table.columnLabels = column_labels;
}

See also