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:
Requirements
- 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)
Methods
Adding significance arrows or carets 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) and going to the object inspector and selecting OUTPUT > Visualization or via the Visualization menu on the toolbar and selecting the table or variables as the DATA SOURCE.
- With the visualization selected, go to Chart > APPEARANCE > Show Significance and select the type of significance visualization you would like to show.
- OPTIONAL: Adjust the Significance arrow size as necessary.
When the option is set to Arrows or Carets, then the color of the arrows will be taken from the color of the data labels if they are shown, otherwise, the chart font color is used. When Colored Arrows or Colored Carets is chosen, the color of the arrows will be taken from the settings found in Properties > APPEARANCE > Significance > Advanced > Significance Levels of the input table.
Using letters for statistical testing
- On your table, add the column comparison letters to the table using Inputs > STATISTICS > Cells > Column Comparisons or Appearance > Significance > Compare columns
- Create a visualization by going to the Inputs tab, and selecting the visualization from OUTPUT > Visualization.
- Go to Chart > DATA LABELS, and tick Show data labels.
- From Annotation (1), select Text - after data label.
- Enter Column Comparisons in Data (cell statistic) (1).
- OPTIONAL: Adjust Size (1) and other 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 from Chart > 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) and Shift left (1) settings:
Hiding labels
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.
The example below modifies a table called table.Preferred.cola.by.age.7, by making all the column comparisons appear as uppercase. This modified table is then used as the input to the visualization.
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.
See Also
How to Apply Multiple Comparison Correction to Significance Tests
Creating and Modifying Visualizations
How to Work with R in Displayr
Comments
0 comments
Article is closed for comments.