2. Exploring Data
a. Categorical Data
Comic Characters Dataset
- 15,516 comic characters from DC and Marvel comics
- Key variables:
- name: Character name
- identity (id): Personal identity status (secret, public, no dual)
- alignment (align): Good, bad, neutral, etc.
Frequency Tables
We can summarize a categorical variable using a frequency table:
| No Dual |
1,511 |
| Public |
6,068 |
| Secret |
7,928 |
| Unknown |
9 |
| Total |
15,516 |
Recall from 1a: A categorical variable takes values that are labels — categories each case falls into.
Summary Statistics
A summary statistic is a single number that summarizes a sample.
For categorical data, the common summary statistics are:
- count — number of cases in each category
- proportion — count ÷ total
- percentage — proportion × 100
Means, medians, and standard deviations are summary statistics for numerical data — that’s the focus of 2b.
Proportions and Percentages
Proportion: What fraction of comic characters have a secret identity?
\[\text{Proportion} = \frac{\text{Count}}{\text{Total}} = \frac{7,928}{15,516} = 0.511\]
Percentage: What percent of comic characters have a secret identity?
\[\text{Percentage} = \text{Proportion} \times 100 = 0.511 \times 100 = 51.1\%\]
Proportions Reveal Patterns
Adding proportions to the table reveals patterns more clearly than raw counts:
| No Dual |
1,511 |
0.097 |
| Public |
6,068 |
0.391 |
| Secret |
7,928 |
0.511 |
| Unknown |
9 |
0.001 |
| Total |
15,516 |
1.000 |
Counts tell you how many. Proportions tell you how much — the share each category takes of the whole.
Proportions
Frequency table for comic character alignment:
| Bad |
7,146 |
| Good |
6,052 |
| Neutral |
2,316 |
| Reformed Criminals |
2 |
| Total |
15,516 |
Compute each — advance for answers:
| Proportion of Good characters |
0.39 |
| Percentage of Bad characters |
46.1% |
| Proportion that are not Neutral |
0.851 |
Bar Plots
We can visualize categorical data using a bar plot:
![]()
Bar length encodes the count — the visual makes it easy to compare categories at a glance.
References