This article describes how to hide rows or columns in a table based on 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 at least two statistics in
**STATISTICS - Cells**, one of which being either*Row n*or*Column n.* - General knowledge of 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**. - OPTIONAL: To have a % appear or to reduce the number of decimals, you can do so from the
**toolbar**.

## 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 %"]

## Next

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

## Comments

0 comments

Article is closed for comments.