Skip to content

Instantly share code, notes, and snippets.

@hungvietdo
Created February 1, 2016 02:55
Show Gist options
  • Save hungvietdo/2c12b2368afb55a1dd7e to your computer and use it in GitHub Desktop.
Save hungvietdo/2c12b2368afb55a1dd7e to your computer and use it in GitHub Desktop.
ICW2: Football data analysis

Team Members: Srinivas Havanur Erika Siregar Hung Do Assignment: ICW2: Football data analysis

Course: Information Visualization

Semester: Spring 2016


Built with blockbuilder.org

Image from http://www.cs.odu.edu/~shavanur/infovis/


1.Scatterplot matrix of passing yards, passing TDs, passer rating, rushing yards, and rushing TDs

R image

Embedding R code in Markdown:

# Scatterplot Matrices
sn <- read.csv("passing-stats-2014.csv", header =T)

# subset data
# Should clean spaces in headings of data
data <- sn[,c("PassingAttempts","PassingYards","PassingTD","Rate","RushingYards","RushingTD")]

#Pairing data into matrix with three different colors
pairs(data,main = "Scatterplot Matrix",pch = 21, bg = c("red", "green3", "blue")[unclass(iris$Species)])

2.Bar chart of passing yards per player (best displayed as a horizontal bar chart), with conference as color

R image

Embedding R code in Markdown:

#Load the csv file using file browse option.
sports <- read.csv(file.choose(), header=TRUE, sep=",")

#It is a package that includes set of functions that attempt to streamline the process for creating predictive models. ggplot is one of the functions in that package. 
library(caret)

#Graph is plotted using ggplot having horizontal bar chart option to represent PassingYards per player.
ggplot(sports, aes(x=sports$Player, y=sports$PassingYards, fill=sports$Conf)) + geom_bar(stat="identity") + coord_flip() + labs(x="Player Names",y="Passing Yards",fill="Conference") + ggtitle("Title: Passing yards per player with conference as color")

3.Bar chart of the average of one of the statistics for each conference

R image

Embedding R code in Markdown:

#Load the csv file using file browse option.
sports <- read.csv(file.choose(), header=TRUE, sep=",")

# This library is loaded to perform groupby summary statistics.
library(doBy)

#It is a package that includes set of functions that attempt to streamline the process for creating predictive models. ggplot is one of the functions in that package. 
library(caret)

#This is used to calculate average of PassingAttempts per conference.
sports_filtered_avg=summaryBy(PassingAttempts ~ Conf, data = sports,FUN = list(mean))

#Graph is plotted using ggplot to represent a bar graph having average of PassingAttempts per conference.
ggplot(sports_filtered_avg, aes(sports_filtered_avg$Conf,sports_filtered_avg$PassingAttempts.mean)) + geom_bar(stat="identity", fill="steelblue") + labs(x="Conference", y="Avg Value") + ggtitle("Title: Avg of PassingAttempts statistics for each Conference")
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
svg { width:100%; height: 100% }
</style>
</head>
<body>
<script>
// Feel free to change or delete any of the code you see!
var svg = d3.select("body").append("svg")
svg.append("rect")
.attr({x: 100, y: 10, width: 700, height: 480})
.style({ fill: "#a72d1a"})
.transition().duration(3000).ease("bounce")
.style({ fill: "#5db9e3"})
console.log("you are now rocking with d3", d3);
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment