This article describes how to go from a table...
...to an output that displays the table percentages when over a certain sample size, otherwise it shows a custom error message.
A table with a sample size statistic showing, such as Column Sample Size or Sample Size. In this example we are using a crosstab with Column % and Column Sample Size.
1. Select your table.
2. Go to Properties > GENERAL > Name and copy the object name.
3. Select Calculation > Custom Code.
4. In the object inspector, go to Properties > R CODE.
5. Reference the name of the table from step 2:
tab = table.exercise.frequency
6. Paste in the rest of the code to display an error message with a specific message when the sample is below a specified threshold:
data = tab[,,"Column %"]
sample.size = max(tab[,,"Column Sample Size"])
if (sample.size < 70)
stop("The sample size is too small for valid analysis.")
How to Handle Outputs with Small or No Data using R
How to Work with Conditional R Formulas
How to Hide an Output with a Small Sample Size Using a Calculation
How to Blank or Cap R Table Cells Based on a Different Statistic Using R
Article is closed for comments.