beanumber / baseball_R

Companion to Analyzing Baseball Data with R, 2nd edition
95 stars 62 forks source link

Chapter 3 code #4

Closed patmetzger closed 10 months ago

patmetzger commented 4 years ago

I'm a beginner here so please excuse my naiveness.

It appears that the book contains out-dated files from the Lahman data base? The Lahman data base that I've downloaded contains only a 'HallOfFame.csv' file and no longer separate ones like the book insinuates - hofbatting.csv & hofpitching.csv?

In order to get around this I read in the data through: hof <- read_csv("Documents/R Project/Baseball/Lahman/core/HallOfFame.csv")

But the next code in the sequence I can't seem to navigate around. The message I keep receiving is "Error: object 'From' not found" for this code: hof$MidCareer <- with(hof, (From + To) / 2) hof$Era <- cut(hof$MidCareer, breaks = c(1800, 1900, 1919, 1941, 1960, 1976, 1993, 2050), labels = c("19th Century", "Dead Ball", "Lively Ball", "Integration", "Expansion", "Free Agency", "Long Ball"))

I've tried to find answers online about the 'From + To' function of the code but cant seem to find anything relevant. There must be an easy solution to this but I'm a beginner so I'm unaware of any easy fixes. Any help to this problem would be much appreciated, Thanks.

beanumber commented 10 months ago

I doubt that this is still relevant, but our advice for how to obtain the Lahman database has changed:

https://beanumber.github.io/abdwr3e/01-datasets.html#obtaining-the-database