<commit_before>---
layout: page
title: NULL
---

[R Vocab Topics](index) &#187; [Analytics](analytics) &#187; Categorical data descriptive statistics

<br>

<img src="/public/images/analytics/descriptives/descriptive_stats_categorical_icon2.png"  style="float:right; margin: -25px 0px -10px 10px; width: 30%; height: 30%;" />
Descriptive statistics are the first pieces of information used to understand and represent a dataset. There goal, in essence, is to describe the main features of numerical and categorical information with simple summaries. These summaries can be presented with a single numeric measure, using summary tables, or via graphical representation. Here, I illustrate the most common forms of descriptive statistics for categorical data but keep in mind there are numerous ways to describe and illustrate key features of data.

<br>

## tl;dr
This tutorial covers the key features we are initially interested in understanding for categorical data, to include:

1. [Frequencies:](#frequencies)  The number of observations for a particular category
2. [Proportions:](#proportions)  The percent that each category accounts for out of the whole
3. [Marginals:](#marginals)  The totals in a cross tabulation by row or column
4. [Visualization:](#visualization) We should understand these features of the data through statistics *and* visualization

<br>

## Replication Requirements
To illustrate ways to compute these summary statistics and to visualize categorical data, I'll demonstrate using this [data](https://github.com/bradleyboehmke/bradleyboehmke.github.io/blob/master/public/data/Supermarket%20Transactions.xlsx) which contains artificial supermarket transaction data.  In addition, the packages we will leverage include the following:

{% highlight r %}
library(readxl)         # for reading in excel data
library(ggplot2)        # for generating visualizations<commit_msg>Update descriptives_categorical.md<commit_after>---
layout: page
title: NULL
---

[R Vocab Topics](index) &#187; [Analytics](analytics) &#187; Categorical data descriptive statistics

<br>

<img src="/public/images/analytics/descriptives/descriptive_stats_categorical_icon2.png"  style="float:right; margin: -25px 0px -10px 10px; width: 30%; height: 30%;" />
Descriptive statistics are the first pieces of information used to understand and represent a dataset. There goal, in essence, is to describe the main features of numerical and categorical information with simple summaries. These summaries can be presented with a single numeric measure, using summary tables, or via graphical representation. Here, I illustrate the most common forms of descriptive statistics for categorical data but keep in mind there are numerous ways to describe and illustrate key features of data.

<br>

## tl;dr
This tutorial covers the key features we are initially interested in understanding for categorical data, to include:

- [Frequencies:](#frequencies)  The number of observations for a particular category
- [Proportions:](#proportions)  The percent that each category accounts for out of the whole
- [Marginals:](#marginals)  The totals in a cross tabulation by row or column
- [Visualization:](#visualization) We should understand these features of the data through statistics *and* visualization

<br>

## Replication Requirements
To illustrate ways to compute these summary statistics and to visualize categorical data, I'll demonstrate using this [data](https://github.com/bradleyboehmke/bradleyboehmke.github.io/blob/master/public/data/Supermarket%20Transactions.xlsx) which contains artificial supermarket transaction data.  In addition, the packages we will leverage include the following:

{% highlight r %}
library(readxl)         # for reading in excel data
library(ggplot2)        # for generating visualizations
{'fraction_non_alphanumeric': 0.07257008121561435, 'fraction_numerical': 0.012051349227141734, 'mean_word_length': 5.3953098827470685, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4425023', 'n_tokens_mistral': 1028, 'n_tokens_neox': 944, 'n_words': 444}