Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/Chap2.introduction.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Age <- 19 : 29
HR.Rates <- hr.rates(Age, HR, AB)
Mantle <- cbind(Age, HR, AB, Rates=HR.Rates$y)

write.csv(Mantle, "..\output\mantle.csv", row.names=FALSE)
write.csv(Mantle, "../output/mantle.csv", row.names=FALSE)

# Section 2.7 Data Frames

Expand Down
12 changes: 6 additions & 6 deletions scripts/Chap3.graphics.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ 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", "Lively Ball", "Dead Ball",
labels = c("19th Century", "Dead Ball", "Lively Ball",
"Integration", "Expansion", "Free Agency",
"Long Ball"))

Expand All @@ -42,7 +42,7 @@ barplot(table(hof$Era))
plot(table(hof$Era))
dev.off()

# Section 2.4 Dot plots
# Section 3.4 Dot plots

T.Era <- table(hof$Era)
dotchart(as.numeric(T.Era), labels=names(T.Era), xlab="Frequency")
Expand All @@ -51,7 +51,7 @@ hof.500 <- subset(hof, HR >= 500)
hof.500 <- hof.500[order(hof.500$OPS), ]
dotchart(hof.500$OPS, labels=hof.500$X, xlab="OPS")

# Section 2.5 Numeric Variable: Stripchart and Histogram
# Section 3.5 Numeric Variable: Stripchart and Histogram

windows(width=7, height=3.5)
stripchart(hof$MidCareer, method="jitter", pch=1,
Expand All @@ -63,7 +63,7 @@ hist(hof$MidCareer, xlab="Mid Career", main="")
hist(hof$MidCareer, xlab="Mid Career", main="",
breaks=seq(1880, 2000, by=20))

# Section 2.6 Two Numeric Variables
# Section 3.6 Two Numeric Variables

with(hof, plot(MidCareer, OPS))
with(hof, lines(lowess(MidCareer, OPS, f=0.3)))
Expand Down Expand Up @@ -127,7 +127,7 @@ bonds.info <- getinfo("Barry", "Bonds")
arod.info <- getinfo("Alex", "Rodriguez")
ruth.info

batting <- read.csv("lahman/Batting.csv")
batting <- read.csv("Batting.csv")

ruth.data <- subset(batting, playerID == ruth.info$name.code)
ruth.data$Age <- ruth.data$yearID - ruth.info$byear
Expand Down Expand Up @@ -186,4 +186,4 @@ text(10440, 65, "62")
legend(10440, 20, legend=c("McGwire (70)", "Sosa (66)"),
lwd=2, col=c("black", "grey"))

#########################################################
#########################################################