Significance Testing in Tables - Show Column Comparisons to the Right of Values
Jump to navigation
Jump to search
Q Technical Reference
Q Technical Reference
Q Technical Reference > Creating And Modifying Tables
Q Technical Reference > Setting Up Data > Creating New Variables
Q Technical Reference > Updating and Automation > Automation Online Library
Q Technical Reference > Updating and Automation > JavaScript > Table JavaScript and Plot JavaScript
Rule Online Library
This rule shows column comparisons to the right of the first statistic's values. Once you have applied this rule you may need to remove the original column comparisons form the cells (Statistics - Cells > Column Comparisons) and add the Column Names (Statistics - Below > Column Names or Modify Headers - Add Column Names to Column Labels).
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
includeWeb('Table JavaScript Utility Functions');
excludeRTables();
form.setHeading("Show Column Comparisons to the Right of Values");
form.setSummary("Show Column Comparisons to the right of values");
let description = form.newLabel("Places the Column Comparisons results within the main cells in the table.");
form.setInputControls([description]);
// If column comparisons is shown, turn it off so not showing twice
table.statistics = table.statistics.filter(function (stat) { return stat != "Column Comparisons"; });
if (table.availableStatistics.indexOf("Column Comparisons") == -1)
form.ruleNotApplicable("Column Comparisons are not available for this table");
let column_comparisons = table.get('Column Comparisons');// Try to get the column comparisons.
let cell_texts = table.cellText;// Get the default text in each cell in the table.
for (let row = 0; row < table.numberRows; row++)// Loop through each cell...
for (let column = 0; column < table.numberColumns; column++) {
// Set the cell text to be the column comparison value for this cell,
// with a space before it.
let comparison_text = column_comparisons[row][column];
// Removing spaces.
let text_without_spaces = comparison_text.replace(/ /g,"");
// Inserting into cell.
if (cell_texts[row][column] == null)
cell_texts[row][column] = table.statistics.map(function (stat, ind) { return (ind == 0 ? ' ' + text_without_spaces : "") });
else
cell_texts[row][column][0] = cell_texts[row][column][0] + ' ' + text_without_spaces;
}
// Now store the new cell texts.
table.cellText = cell_texts;
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.
Q Technical Reference
Q Technical Reference
Q Technical Reference > Creating And Modifying Tables
Q Technical Reference > Setting Up Data > Creating New Variables
Q Technical Reference > Updating and Automation > Automation Online Library
Q Technical Reference > Updating and Automation > JavaScript > Table JavaScript and Plot JavaScript
Rule Online Library