Introduction
This article describes how to go from a standard table...
...to a CreateCustomTable R table (similar to a table with Autofit checked) that colors significant cells:
...or a CreateCustomTable R table that shows significant arrows:
Requirements
- A table showing the z-Statistic.
Method
1. Right click on your table and select Reference Name.
2. Copy this reference name somewhere to use in your code later.
3. Right click on the Report tree and select Add R Output.
4. Paste the below under Properties > R CODE:
#identify mytable
mytable = table.D2.Income
#create default table to store sig fills
sigs = rep(0,NROW(mytable))
#mark -1 for neg sig and 1 for pos sig
sigs[mytable[,"z-Statistic"] < -1.96] = -1
sigs[mytable[,"z-Statistic"] > 1.96] = 1
#mark NET sig 0
sigs[length(sigs)] = 0
#create custom table
flipFormat::CreateCustomTable(mytable[,"%"],
sig.change.fills=sigs,
col.header.labels="%",
col.width=c("60%"),
row.header.align.horizontal="right",
row.header.pad=3)
- The above code defines the table using the reference name from step 2.
- Next, we create an output called sigs to store a 1 if significantly higher, 0 if not significant, and -1 if significantly lower. In this example, the significance level is set at 95%.
- Finally, we use our CreateCustomTable function from the flipFormat R package and parse sigs into the sig.change.fills argument.
5. Right click on the R Output and select Calculation Options.
6. Change Exporting > Format > To PowerPoint as Image of R Output. Note that this means you cannot edit the table once it is exported to PowerPoint.
7. OPTIONAL: To display arrows instead of color fills, change sig.change.fills to sig.change.arrows.
8. OPTIONAL: To change the fill colors, add the sig.fills.up and sig.fills.down arguments.
9. OPTIONAL: To change the significance arrow colors, add the sig.arrows.up and sig.arrows.down arguments.
10. OPTIONAL: Add other arguments to CreateCustomTable to set colors, padding and font styles.
Note, you can reference colors by HTML name, HEX, and rgb, e.g. rgb(255,255,255).
See Also
How to Customize a Table using CreateCustomTable in R
How to Customize Fonts in a CreateCustomTable R Table
How to Add Row Spans to a CreateCustomTable R Table
How to Add Column Spans to a CreateCustomTable R Table
How to Customize a Table with Multiple Statistics using CreateCustomTable in R