jsalvatore
2/8/2015 - 2:52 PM

slugger_graphic1.R

#reorder the factor level in order so we can cleanly see the RBIs and their varibility among these sluggers
hrs$nameyear <- factor(hrs$nameyear, levels=hrs[order(hrs$RBI), "nameyear"])
#create a flipped bar plot and gradient fill the bars with the corresponding HRs
ggplot(data=hrs, aes(x=nameyear, y=RBI, fill=HR)) + geom_bar(stat="identity") +
  coord_flip() + scale_fill_gradient(low="gray50", high="red")