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.
- # http://www.nirpata.com
- library(XML)
- library(ggplot2)
- library(RColorBrewer)
- library(colorRamps)
- # Goal scored time
- url <- "http://www.uefa.com/worldcup/season=2014/statistics/round=2000296/goaltimes/index.html"
- goaltime <- readHTMLTable(url)
- goaltime
- goaltime <- do.call(rbind.data.frame, goaltime)
- str(goaltime)
- Goal.Total <- as.numeric(as.character(goaltime$Total))
- Goaltime.data <- data.frame(goaltime, Goal.Total)
- # Expanding colorpallete
- colourCount = length(unique(Goaltime.data$Time))
- getPalette = colorRampPalette(brewer.pal(9, "Set1"))
- # plot with custom pallete
- goaltime.graph <- ggplot(data=Goaltime.data, aes(x=Time, y=Goal.Total, fill=Time)) + geom_bar() + scale_fill_manual(values =getPalette(colourCount)) + theme(axis.text.x=element_text(angle = -90, hjust = 0)) + theme(legend.position="none")
- goaltime.graph
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement