Six numbers per Pokémon, where the new axes come from, and what ‘variance explained’ means
pca
multivariate
prcomp
ggplot
plotly
pokemon
A first, gentle pass at principal component analysis on all 1,025 Pokemon, assuming no statistics background at all. Three stats in an interactive 3-D plot (and why six cannot be drawn), the correlation table, why correlated columns are not dropped, where PC1 comes from using two stats, the shadow analogy, scaling, running prcomp(), variance explained, the scree plot, checking PC1 against who sits at each end, and a hover-to-name plot of the new axes.
Author
Bill Perry
Published
November 30, 2026
Something Completely Different
Everything this term had one response variable
t-test: one measurement, two groups
regression: one measurement against one other
ANOVA: one measurement across several groups
Today: six measurements at once, and no groups to compare
not “is A different from B?”
but “what is the shape of this whole dataset?” 🔴
Today Has No p-Values
PCA is not a test
no null hypothesis
no p-value
no assumptions to check
nothing passes or fails
It is a way of looking at data that has too many columns to plot
The question is never “is it significant?”
it is always “does this make sense?”
Important
⚠️ Set down one habit
For nine weeks, “did it work?” meant “is p small?”
Today you judge your result by whether you can explain what the axes mean.
Goals for Today
See the data in 3-D — and why six columns cannot be drawn
Notice that the columns are correlated
See where a principal component comes from
Know why you must scale first
Run it: prcomp()
Read variance explained, draw a scree plot
Check PC1 against Pokémon you already know
Hover over the new picture to find them
Tools today:
tidyverse
plotly — you installed it for the mapping weeks
Data: 🔴 all 1,025 Pokémon, six battle stats each
Tip
No new packages.prcomp() is built into R.
Why Pokémon
Because you can check the answer
PCA hands back new axes that it invented
you have to decide whether they mean anything
that is nearly impossible on data you do not know
If an axis puts Magikarp at one end and Mewtwo at the other, you know exactly what it found
1,025 is plenty of data — and hovering tells you who any dot is
Same method as gene expression, soil chemistry, skull measurements
Note
📖 The six stats
hp — hit points
attack — physical attack
defense — physical defence
sp_attack — special attack
sp_defense — special defence
speed — speed
Game-design numbers, but they behave exactly like six measurements off an animal.
# A tibble: 3 × 2
status n
<chr> <int>
1 legendary 71
2 mythical 23
3 regular 931
1,025 rows — one per Pokémon
status is one column built from two TRUE/FALSE ones
first matching line wins
TRUE ~ catches everything left over
We will colour by status — PCA never sees it
Note
🧠 Mythical?
A second “rare and special” group in the game — Mew is mythical, Mewtwo is legendary.
Three Stats, in 3-D
plot_ly(pokemon, x =~attack, y =~defense, z =~speed,color =~status, text =~name,colors =c("firebrick", "darkorange", "grey60"),type ="scatter3d", mode ="markers", marker =list(size =3))
What That Plot Shows
Drag to rotate it — every dot is one Pokémon
from some angles: a shapeless blob
from others: a long, spread-out cloud
same data, different amount you can see
Hover — the name pops up
red / orange (legendary, mythical) sit out at the big end
But this is only 3 of the 6 stats
hp, sp_attack, sp_defense are missing
Important
✅ Hold on to this
Rotating to find the angle that shows the most spread is exactly what PCA does.
It just does it in six dimensions, where we cannot rotate anything by hand.
Six Columns Is Too Many to Plot
One measurement → a histogram
Two → a scatterplot
Three → the 3-D plot you just spun
Six → nothing
there is no six-dimensional plot, and never will be
All the pairs instead? 15 scatterplots
nobody can hold 15 plots in their head
Warning
⚠️ The real problem
“Which Pokémon are similar to each other?” is a question about all six numbers at the same time.