## Introduction

This article describes how to hide rows or columns in a table based upon their sample size. You can go from a table showing all the data:

To a table that only shows data for rows/columns with sufficient data (I'm using a Row n threshold of 20 for the table below):

## Requirements

- A table showing two statistics in
**STATISTICS - Cells**, one of which being either*Row n*or*Column n.* - General knowledge on How to Work with Data in R and How to Work with Conditional R Formulas.

## Method - Hide Rows

In this example, we'll hide all rows with a Row n of less than 20 - in the first column. If you have different bases for the different columns, you can specify a different column to use.

- Right click on the
**Report**tree and select**Add R Output**. - Paste the code below into your
**R CODE**box. Change*table.Preferred.cola.by.Quarterly.dates.6*to the name of your table, and edit the threshold of*20*and final statistic to show (currently*Column %*) as needed.#identify table

x=table.Preferred.cola.by.Quarterly.dates.6

#identify rows with sample sizes above 20 in the first column

#change 20 if needed

keeprows=x[,1,"Row n"] > 20

#return table without those rows

#return the Column % or change that to the other stat in your table

x[keeprows,,"Column %"] - Click
**Calculate**.

## Method - Hide Columns

Similar to above, if you'd like to remove columns based on *Column Sample Size* of 20 you can use the code below:

#identify table

x=table.Preferred.cola.by.Quarterly.dates.6

#identify cols with sample sizes above 20 in the first row

#change 20 if needed

keepcols=x[1,,"Column n"] > 20

#return table without those cols

#return the Column % or change that to the other stat in your table

x[,keepcols,"Column %"]

## See Also

How to Reference Different Items in Your Project in R

How to Work with Conditional R Formulas

How to Remove a Row or Column from a Table Using R

How to Relabel Rows and Columns in an R Table

How to Hide Rows and Columns with Small Sample Sizes in a Table

How to Blank and Cap Cells of Tables Using R in Q

## Comments

0 comments

Article is closed for comments.