Adding a Column Header Footnote Indicating Small Sample Sizes

From Q
Jump to navigation Jump to search

Whenever a Column n is less than 30, adds an asterisk next to the column name, and add a footnote explaining the asterisk. Note that this will only work on tables that contain Column n.

var column_ns = table.get('Column n');// Get the Column N statistics.
var column_labels = table.columnLabels;// Get the column labels.
var footnotes = table.extraFooters;// Make a list of extra footnotes.
for (var column = 0; column < table.numberColumns; column++) {// For each column...
      var column_n = column_ns[0][column];// Get the column n statistic (from the cell in the first row).
      if (column_n < 30) {
            footnotes.push('* column "' + column_labels[column] + '" has less than 30 respondents.');// Add an extra footnote.
            column_labels[column] += '*';// Put a marker on this column's label.
   }
}
table.columnLabels = column_labels;// Store the adjusted column labels and footnotes.
table.extraFooters = footnotes;

See also