## Introduction

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**.

Please note these steps require the **Data Stories** module or a **Displayr **license.

## Method

1. Select your table.

2. Go to **General > GENERAL > Name** and copy the object name.

3. Select the** Calculation icon > Custom Code**.

4. In the **object inspector**, go to **General > 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.")

data

## See Also

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