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 summary table showing the z-Statistic
Method
1. Select your table.
2. Copy the name from Properties > GENERAL > Name.
3. Go to Calculation > Custom code.
4. Click onto the page to place the custom calculation.
5. 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.
6. OPTIONAL: To display arrows instead of color fills, change sig.change.fills to sig.change.arrows.
7. OPTIONAL: To change the fill colors, add the sig.fills.up and sig.fills.down arguments. You can reference colors by name and rgb, e.g. rgb(255,255,255).
8. OPTIONAL: To change the significance arrow colors, add the sig.arrows.up and sig.arrows.down arguments. You can reference colors by name and rgb, e.g. rgb(255,255,255).
9. OPTIONAL: Add other arguments to CreateCustomTable to set colors, padding, and font styles.
Next
Comments
0 comments
Article is closed for comments.