Modify Footers - Add Column Header Footnote Indicating Small Sample Sizes
		
		
		
		Jump to navigation
		Jump to search
		
This rule adds an asterisk to the column header and adds a footnote whenever a Column n is less than a user-specified amount (default is 30).
Example
How to apply this rule
For the first time in a project
- Select the table(s)/chart(s) that you wish to apply the rule to.
 - Start typing the name of the Rule into the Search features and data box in the top right of the Q window.
 - Click on the Rule when it appears in the QScripts and Rules section of the search results.
 
OR
- Select Automate > Browse Online Library.
 - Choose this rule from the list.
 
Additional applications of the rule
- Select a table or chart that has the rule and any table(s)/chart(s) that you wish to apply the rule to.
 - Click on the Rules tab (bottom-left of the table/chart).
 - Select the rule that you wish to apply.
 - Click on the Apply drop-down and choose your desired option.
 - Check New items to have it automatically applied to new items that you create. Use Edit > Project Options > Save as Template to create a new project template that automatically uses this rule.
 
Removing the rule
- Select the table(s)/chart(s) that you wish to remove the rule from.
 - Press the Rules tab (bottom-right corner).
 - Press Apply next to the rule you wish to remove and choose the appropriate option.
 
How to modify the rule
- Click on the Rules tab (bottom-left of the table/chart).
 - Select the rule that you wish to modify.
 - Click Edit Rule and make the desired changes. Alternatively, you can use the JavaScript below to make your own rule (see Customizing Rules).
 
JavaScript
var stat_name = table.getTranslation("Column n");
if (table.availableStatistics.indexOf('Column n') == -1)
    form.ruleNotApplicable('this format only applies to tables with the ' + stat_name +
			   ' statistic');
// Set up controls for user input.
form.setHeading('Adding a Column Header Footnote Indicating Small Sample Sizes:');
var label = form.newLabel('Minimum ' + stat_name + ':');
var numeric_up_down  = form.newNumericUpDown('threshold');
numeric_up_down.setDefault(30);
numeric_up_down.setIncrement(1);
numeric_up_down.setMaximum(999999999);
form.setInputControls([label, numeric_up_down]);
var min_column_n = numeric_up_down.requireValue();
form.setSummary('Add a column header footnote when ' + stat_name + ' < ' +
		min_column_n);  
var footnote_flag = false;
var column_ns = table.get('Column n');// Get the Column N statistics.
var column_labels = table.columnLabels;// Get the column labels.
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 < min_column_n) {
        column_labels[column] += '*';// Put a marker on this column's label.
        footnote_flag = true;
    }
}
if (footnote_flag) {
    table.columnLabels = column_labels;// Store the adjusted column labels and footnotes.
    var footnotes = table.extraFooters;// Make a list of extra footnotes.
    footnotes.push('*column has less than ' + min_column_n + ' respondents.');// Add an extra footnote.
    table.extraFooters = footnotes;
}
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.
 
