-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotData.R
43 lines (38 loc) · 1.38 KB
/
plotData.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# plotData.R
#
# Purpose: Plot a bar chart where the x-axis lists the names of all players
# on the team, and the y-axis lists salaries in millions of dollars.
#
# Author: Jedid Ahn (jedid.ahn@mail.utoronto.ca)
#
# Date: 2018-08-04
#
# ==============================================================================
plotData <- function(combinedData, year, team){
barplot(combinedData$actual_salary / 1000000,
las = 2,
ylab = "Salary in millions of dollars (USD)",
names.arg = combinedData$last_name,
main = paste("Moneyball Value of", year, team, "players",
sep = " "),
# Scale is structured according to the highest salary.
ylim = range(pretty
(c(0,
max(combinedData$actual_salary / 1000000,
combinedData$deserved_salary / 1000000) + 1)
)),
col = "#FF000055")
barplot(combinedData$deserved_salary / 1000000,
las = 2,
add = TRUE,
col = "#32CD3255")
# Allows for legend to be outside of plotting region.
par(xpd = TRUE)
legend("topright",
c("Actual", "Deserved"),
fill = c("#FF000055", "#32CD3255"),
cex = 0.8,
inset = c(-0.09,-0.18),
bty = 'n')
}
# [END]