Introduction
This article describes how to create a CreateCustomTable R table (similar to a table with Autofit checked) to align sample sizes to bars on a visualization.
Requirements
1. A visualization
2. A table that includes the same categories as the visualization and the values you'd like to show aligned to the visualization. In this example, the table has been sorted based on percentage and the Count statistic will be used for the sample size:
Method
1. Go to Calculation > Custom Code in the toolbar.
2. Paste the below under Properties > R CODE:
#specify your table and the statistic you'd like to use
#if the statistic is not in its own column, replace [,"Count"] with [,,"Count"]
n = as.vector(table.Q3.Preferred.cola[,"Count"])
#add a prefix to each count
n = paste0("n=",n) # Add 'n=' to each value
# Create the custom table that can resize the data to align with the visualization
flipFormat::CreateCustomTable(n,
font.size=10,
transpose = T)
- The above code pulls in the Count values from our cola brand table without the row headers. To apply this in your own document, you should replace the table reference on the first line of the code.
- We then use the paste0 function to add the prefix of "n=" to each individual sample size.
- Finally, we use flipFormat's CreateCustomTable function to display the sample sizes in a smaller font and transpose them as a single row.
3. Re-position and re-size your custom table by dragging until it lines up with your visualization with the correct spacing.
See Also
How to Create an AutoFit Table of Images
How to Work with R in Displayr
How to Add Customized Footers and Sample Size Widgets
Comments
0 comments
Article is closed for comments.