Skip to content

Instantly share code, notes, and snippets.

@juliettepardue
Last active February 3, 2016 04:45
Show Gist options
  • Save juliettepardue/34620b4fb399c8501b2e to your computer and use it in GitHub Desktop.
Save juliettepardue/34620b4fb399c8501b2e to your computer and use it in GitHub Desktop.
ICW2

#Juliette Pardue, Mridul Sen, Christos Tsolakis

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

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

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

# 1. scatterplot matrix of passing yards, passing TDs, passer rating, rushing yards, and rushing TDs
pairs(passing.stats.2014[,c("Passing.Yards","Passing.TD","Rate","Rushing.Yards","Rushing.TD")])

# 2. bar chart of passing yards per player (best displayed as a horizontal bar chart), with conference as color
storingdata = read.csv("passing-stats-2014.csv")//Reading from file

barplot(storingdata$Passing.Yards,names.arg=storingdata$Player,
las=1,main="Number of Passing yards per Player",horiz=TRUE,cex.names=.5,
col = c("red","green","yellow","brown","black","chocolate4","blueviolet","hotpink",  //Barplot(Horizontal)of passing yards per player 
"darkseagreen4","blue","darkgray")[as.numeric(storingdata$Conf)],
ylim=c(0,150),yaxs="i",xlim=c(0,4500))

legend("topright", c("ACC","American","Big12","Big10","CUSA","Ind","MAC","MWC","Pac12","SEC","Sunbelt"),pch=15, 
       col=c("red","green","yellow","brown","black","chocolate4","blueviolet","hotpink",
"darkseagreen4","blue","darkgray"),bty="n")   //Legends to define which color is for what conference

# 3. bar chart of the average of one of the statistics for each conference
storingdata = read.csv("passing-stats-2014.csv")//Reading from file

aggregate(Passing.Attempts ~ Conf, storingdata, FUN = function(Passing.Attempts)c(mean(Passing.Attempts)))//Aggregating the mean passing attempts per conference

new<-aggregate(Passing.Attempts ~ Conf, storingdata, FUN = function(Passing.Attempts)c(mean(Passing.Attempts))) //Storing the aggregated result into new

data1<-new$Conf

barplot(new$Passing.Attempts,names.arg = data1,las=1,horiz=TRUE,xlab="Average Passing Attempts",
ylab="Conferences",main="Average Passing Attempts per Conference",cex.names=.8,col = c('darkslategray1')) //Plotting the mean passing attempts per conference horizontally
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment