This article describes how to go from a visualization that does not display annotations or significance testing:
To a visualization that displays annotations and significance testing:
- A Displayr document with at least one table.
- Knowledge of how to create visualizations (See: Creating and Modifying Visualizations)
- Familiarity with the types of significance testing in Displayr (See: How to Apply Significance Testing in Displayr)
Adding significance arrows, carets or triangles to Bar, Column, Line, and Radar visualizations
- Create a bar, column, line, or radar visualization by selecting an existing table (that doesn't show Column Comparison stat testing)
- From the object inspector, select OUTPUT > Visualization or via the Visualization menu on the toolbar, selecting the table or variables as the DATA SOURCE.
- With the visualization selected, go to Properties > APPEARANCE > Significance and select Advanced from the pull-down menu
- Select the Exception Tests tab and use the Significance Symbol menu to select the symbol you want to use to indicate significance. In this example, we will choose a Triangle.
- Click Apply to Selection.
- OPTIONAL: Use Chart > APPEARANCE > Significance arrow size to adjust the size of the significance arrow (triangle) as necessary.
- OPTIONAL: Use Significance > Advanced > Significance Levels to change the color of the significance symbol as needed.
Using letters for statistical testing
To add column comparison letters to your table:
- Select Properties > APPEARANCE > Significance > Advanced.
- Click the Significance Levels tab, and from the Show significance menu, select Compare columns.
- Click Apply to Selection.
- Create a visualization by going to the Inputs tab, and selecting the visualization from OUTPUT > Visualization.
- From the Visualization Selector, select Column > Column with Tests.
- OPTIONAL: Click Chart to adjust the formatting as necessary.
Later in the post, another example shows how to change all the letters to uppercase.
Circles, circles with borders, and shadows
In addition to arrows, carets, and text, it is possible to add a border around the data labels, which appears as a filled circle, empty circle with border, or shadow. These are selected as follows:
- Select Chart > DATA LABELS.
- Check the Show data values box.
- Select DATA LABELS > Annotation(1).
There are formatting options for controlling their size, colors, and line thicknesses.
In the example below, I've used the Circle - thick outline annotation type and adjusted the Size (1) setting:
By setting Annotation (1) to Hide, rules can be used to hide annotations. For example, in the chart below, all non-significant labels have been hidden. Note that this also hides the data label.
Creating custom statistics for annotations
All the examples so far have used existing tables and their statistics to create the annotations. However, it's possible to create new tables via R code.
In this example, the following code modifies a table called table.Preferred.cola.2.by.Age.6, by making all the column comparisons appear as uppercase. This modified table is then used as the input to the visualization.
x = table.Preferred.cola.2.by.Age.6
x[,,"Column Comparisons"] = toupper(x[,,"Column Comparisons"])
table.with.upper.case.stats = x
This last example creates a table, with a completely new statistic, called Comment and passes this through to the bar chart, with two annotations. Annotation (1) is set to Hide (to hide the labels) and Annotation (2) to Text - after label with Data (cell statistic) (2) set to Comment.
Looking at the R code used to create the table with the comment, key features are:
- A 3-dimensional array is created called out (this is the required structure of a table for use with annotation). Note that this three dimensional array is a table, where there are multiple results in each cell of the table. In this case, the table has 12 rows and 1 column, where nrow(x) is the 12 rows of the table called table.Interview.Date (shown on the left). The first result in the cells of the table is % and the second is Comment.
- The Comment has been set to blank, except for July 2019, which has been set as New\ncampaign, where \n is the code for a new line.