Adding a Column Header Footnote Indicating Small Sample Sizes
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
- Table JavaScript and Plot JavaScript for an explanation of how to run this code.
- Table JavaScript and Plot JavaScript Reference for technical information.
- Table JavaScript and Plot JavaScript Examples Library for other examples.
- JavaScript for information about the JavaScript programming language.
- QScript for tools for automating projects using JavaScript.
- JavaScript Variables for detail on how to create new variables in the Variables and Questions tab using JavaScript.