By Teja Kodali
Recently, I came across this great visualization of MLS Player salaries. I tried to do something similar with ggplot2, and while I was unable to replicate the interactivity or the tree-map nature of the graph, the graph still looks pretty cool.
Data
The data is contained in this pdf file. I obtained a CSV file extracted from the PDF file by using PDFtables.com. The data can be found here.
Exploratory Analysis
We will need the plyr
and ggplot2
libraries for this. Let’s load them up and read in the data. To learn more about ggplot2
read my previous tutorial.
library(plyr) library(ggplot2) salary Club Last.Name First.Name Pos X Base.Salary X.1 Compensation 1 NY Abang Anatole F $ 50,000.00 $ 50,000.00 2 KC Abdul-Salaam Saad D $ 60,000.00 $ 73,750.00 3 CHI Accam David F $ 650,000.00 $ 720,937.50 4 DAL Acosta Kellyn M $ 60,000.00 $ 84,000.00 5 VAN Adekugbe Samuel D $ 60,000.00 $ 65,000.00 6 POR Adi Fanendo F $ 651,500.00 $ 664,000.00
The X and X.1 columns have nothing but the $ sign, so we can remove them. Also, the base salary is stored as factor. To convert to numeric, first …read more
Source:: r-bloggers.com