# Tribute to Junior

I’m sure many of us are happy that Ken Griffey Jr. was elected to the Hall of Fame yesterday. Junior was a very popular player who had a beautiful swing. Like Mike Trout, he had an immediate impact on the game when he joined the Mariners in 1989. Like Trout, he had a joy for the game that was obvious.

I thought it would be interesting to look at Junior’s offensive and defensive performance over the seasons of his career against similar great players.

Who should we compare Junior with? Looking at Griffey’s at the similarity scores on his Baseball Reference page, we see that Griffey was most similar to Mickey Mantle (ages 21, 23, 24), Frank Robinson (ages 26-32 and 37-40) and Sammy Sosa (ages 33-36). So I’ll compare Griffey with Mantle, Robinson, and Sosa (all great outfielders). By the way, Griffey, Mantle, and Robinson are all members of the HOF and Sosa is unlikely to be inducted due to his alleged use of steroids.

I’ll paste the entire R script below, but here’s what I did to create the graphs.

1. Using the ` readHTMLTable ` function from the ` XML ` package, I directly read in all of the tables from the Baseball Reference web pages for these four tables. In each case, I’m focusing on the table that gives the Age and WAR statistics for all seasons.

2. I write a small function ` clean.data ` that collapses the values of offensive and defensive WAR over seasons (Griffey, for example, played for multiple teams in a single season).

3. Last, I combined the WAR data frames for the four players, and created the graphs using the ` ggplot2 `. The ` facet_wrap ` function makes it easy to create multiple panels and the ` geom_smooth ` function provides the loess smoothing curves.

Here’s the comparison of the four players using the offensive WAR measure of performance.

We see that Griffey, Robinson, and Mantle all were strong offensive players in their 20’s — in contrast, Sosa peaked later in his career. From a raw offensive WAR perspective (not making any adjustment for era), Mantle had the best peak performance at age 25. Griffey and Robinson had long careers, Mantle’s career abruptly ended at age 26, and Sosa had a steep decline between ages 32 and 37.

To see how they compared defensively, I construct a similar play of their season defensive WARS.

Before I drew this graph, I thought that Mantle and Griffey were great in defensive, and I had less knowledge about Robinson and Sosa. Actually this graphs shows that Griffey and Sosa were both great defenders in their 20’s, although both players declined in performance in their 30’s. Mantle only had positive dWAR values for a few years in his 20’s and Robinson had primarily negative dWAR values, indicating that he was generally worse than a replacement player defensively.

As promised, here is the R script. I’d encourage you to modify this script to compare Junior with other players.

```library(XML)
library(ggplot2)
library(dplyr)

clean.data <- function(data, name){
mutate(data, Age=as.numeric(as.character(Age)),
oWAR=as.numeric(as.character(oWAR)),
dWAR=as.numeric(as.character(dWAR))) -> data
summarize(group_by(data, Age),
dWAR=sum(dWAR), oWAR=sum(oWAR)) -> S
mutate(S, Player=name)
}

Mick <- clean.data(mantle, "Mickey Mantle")
Sammy <- clean.data(sammy, "Sammy Sosa")
Frank <- clean.data(frank, "Frank Robinson")
Junior <- clean.data(junior, "Ken Griffey Jr.")

ggplot(rbind(Mick, Sammy, Frank, Junior),
aes(Age, oWAR)) + geom_point() + geom_smooth() +
facet_wrap(~ Player, ncol=2) +
geom_hline(yintercept=0, color="red") +
ggtitle("Season Offensive WAR Values")

ggplot(rbind(Mick, Sammy, Frank, Junior),
aes(Age, dWAR)) + geom_point() + geom_smooth() +
facet_wrap(~ Player, ncol=2) +
geom_hline(yintercept=0, color="red") +
ggtitle("Season Defensive WAR Values")
```

### 2 responses

1. Jim,

Curious about the players who “allegedly” used steroids – Sosa, Bonds, etc – is it possible to run a query that show outliers of players who continued to excel when a majority of players started to decline all based on age? Would like to see what players continued to post above average numbers when the data shows overall that a decline should been starting.

Thx,
Jeff

1. Jeff: That would be interesting to look at. Some years ago, I explored trajectories of sluggers and a few like McGwire, Sosa and Bonds, display patterns that are different from typical aging patterns. But I haven’t done a complete analysis.