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.
Requirements
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.
Method
1. Select your table.
2. Go to General > General > Name and copy the object name.
3. Select Calculation > Custom Code from the toolbar and click on the page to place the object.
4. In the R Code editor, reference the name of the table from step 2. In this example: tab = table.exercise.frequency
5. 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.")
data
Next
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