Advertisement
Guest User

foulbyquarterfinalers

a guest
Jul 5th, 2014
1,075
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.03 KB | None | 0 0
  1. # Written by Haseeb Mahmud
  2. # Requirements  : R 3.0 or higher with appropriate libraries installed.
  3. #               : Internet connection
  4. #               : R studio Environment.
  5. # Data      : YahooSports  
  6.  
  7. # Foul yahoo sports
  8. Fouls <- c(96, 90, 61, 57, 76, 81, 40, 73)
  9. Countries <- c("Brazil", "Columbia", "France", "Germany", "Netherlands", "Costarica", "Argentina", "Belgium")
  10. MathesPlayed <- c(5, 5, 5, 5, 4, 4, 4, 4)
  11. AvFouls <- Fouls/MathesPlayed
  12. Fouldata <- data.frame(Fouls, Countries, MathesPlayed, AvFouls)
  13.  
  14. # Reordering the data to fit it into the plot
  15. countriesfoul <- transform(Fouldata, Countries = reorder(Countries, AvFouls))
  16.  
  17. # Expanding colorpallete
  18. colourCount <- length(unique(Fouldata$Countries))
  19. getPalette <- colorRampPalette(brewer.pal(9, "Set1"))
  20. # plot with custom pallete  
  21. foul.graph <- ggplot(data=countriesfoul, aes(x=Countries, y=AvFouls, fill=Countries)) + geom_bar() +  scale_fill_manual(values =getPalette(colourCount)) + theme(axis.text.x=element_text(angle = -90, hjust = 0)) + coord_flip()
  22. foul.graph
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement