# How to Calculate an Average Value from Categorical Data in Displayr

The traditional means for outputting categorical data is with percentages representing each category's share of the total sample. However, there are a range of cases where it is useful to calculate an average value based on the categories.

This requires that each category in the data be associated with a meaningful value, so that the average is also meaningful. In this post we look at how assign numeric values categories in Displayr so that averages can be calculated.

## Recoding

To calculate the average value for a categorical question, a numeric value must be assigned to each category. In the following case, respondents were asked to choose from categorical, single-response options with numeric range labels instead of asking respondents to enter a specific value.

In order to calculate an average in this situation, a numeric value must be assigned to each category that best represents the entire category. The commonly accepted best practice for this is with midpoint coding. This process codes the value for each category with its midpoint with the limitation that this average will only be an estimate or a “ballpark” value.

To recode values in Displayr:

- Select a Variable Set from the
**Data Sets**section in the bottom left. - Click the Value Attributes button in the Object Inspector on the right.
- Enter appropriate values for each category in the
**Value**column. - Click
**OK**.

In some other cases, each category has numerical values that someone has predefined, like scale questions. Take a look at the following satisfaction question which someone has coded with 5 for “Extremely satisfied”, 4 for “Satisfied”, and so on.

You can easily average the results for this question. The closer the overall average is to 5, the higher the level of satisfaction. Using the average also allows for easy crosstab comparison of sub-groups. You can apply this approach to virtually any scale-type question from which you can easily derive an average.

## Showing the average statistic

Once you have confirmed these settings, you can add the average statistic to the bottom of the table.

- Drag a
*Variable Set*onto your page. - In the
**Inputs**section of the Object Inspector, change the**STATISTICS > Below**to include**Average**.

## Change variable set structure to Numeric / Numeric - Multi

If the only statistic you want to show on a table is the average, changing the variable set Structure into either **Numeric** or **Numeric - Multi **format can be a more sensible and direct option. By default, Displayr will always output the average statistic on tables utilizing these question types. Changing the structure makes it much easier to create crosstabs when comparing results for multiple items.

To do so:

- Select a variable set from
**Data Sets**. - In the
**Properties**section of the Object Inspector, change the question structure to either**Numeric**or**Numeric - Multi**.

**We hope you found this guide helpful. Discover how to do more in Displayr. **