Contact me at the buttons in the footer!
Position <- read.csv("WAR by Position.csv", header=TRUE)
library(treemap)
#https://rdrr.io/cran/treemap/man/treemap.html
Position = subset(Position, Normalized.WAR >0)
Position$League = ifelse(Position$Team %in% c("Cardinals", "Brewers", "Cubs", 'Reds', "Pirates", "Mets", "Nationals", "Dodgers", "Marlins", "Braves", "Phillies", "Dodgers", "Giants", "Padres", "Rockies", "Diamondbacks"), "NL", "AL")
Position =subset(Position, League == "NL")
Position = subset(Position, Pos != "P")
treemap(Position,
index=c("Pos","Name"),
vSize = "Normalized.WAR",
vColor = 'Normalized.WAR',
type="manual", #Type sets the organization and color scheme of your treemap
palette = "Blues", #Select your color palette from the RColorBrewer presets or make your own.
title="2018 WAR by Position National League", #Customize your title
fontsize.title = 14,#Change the font size of the title
title.legend = "Normalized WAR",
algorithm = "squarified" #Sorting order
)