Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Written by Haseeb Mahmud
- # Requirements : R 3.0 or higher with appropriate libraries installed.
- # : Internet connection
- # : R studio Environment.
- # Data : YahooSports
- # Foul yahoo sports
- Fouls <- c(96, 90, 61, 57, 76, 81, 40, 73)
- Countries <- c("Brazil", "Columbia", "France", "Germany", "Netherlands", "Costarica", "Argentina", "Belgium")
- MathesPlayed <- c(5, 5, 5, 5, 4, 4, 4, 4)
- AvFouls <- Fouls/MathesPlayed
- Fouldata <- data.frame(Fouls, Countries, MathesPlayed, AvFouls)
- # Reordering the data to fit it into the plot
- countriesfoul <- transform(Fouldata, Countries = reorder(Countries, AvFouls))
- # Expanding colorpallete
- colourCount <- length(unique(Fouldata$Countries))
- getPalette <- colorRampPalette(brewer.pal(9, "Set1"))
- # plot with custom pallete
- 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()
- foul.graph
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement