Skip to content

Instantly share code, notes, and snippets.

View kevindesai777's full-sized avatar
:octocat:

Kevin Desai kevindesai777

:octocat:
View GitHub Profile
@kevindesai777
kevindesai777 / English Football Blog Post Code
Last active August 29, 2015 14:07
The entire code for the blog post
#Grouping the matches by season
df_season <- df %>% #%>% is a special operator which translates to 'then' in English.
group_by(Season) %>%
summarise(HomeGoals = sum(hgoal), AwayGoals = sum(vgoal), HomeWins = sum(result == 'H'), AwayWins = sum(result =='A'), Draws = sum(result == 'D'))
#Grouping the matches by full time scores
df_scoreline <- df %>%
group_by(FT) %>%
summarise(count=n()) %>%
arrange(desc(count))
@kevindesai777
kevindesai777 / Loading Data into R
Last active August 29, 2015 14:07
Loading the data into the Data Frame in R
library(devtools)
library('dplyr')
install_github('engsoccerdata', username = "jalapic")
library(engsoccerdata)
data(package="engsoccerdata")
df = engsoccerdata2
df =tbl_df(df) #Converts it to a local data frame (Better printing options than regular data frame)
@kevindesai777
kevindesai777 / Q2Code
Created October 5, 2014 10:17
Question 2 Code for Striker
player = read.csv('Football_Player.csv')
Ballon <- player %>%
group_by(Name.of.Player) %>%
summarise('BallonAward' = sum(((Total.Goals+Assists)*0.5)+(0.2*((Shot.Accuracy/100)+(Pass...Percentage/100)))-((0.1))*Fouls...Committed)-((0.2)*Cards...Total))
Ballon <- mvp %>%
arrange(desc(BallonAward))
playerStat <- player %>%
group_by(Name.of.Player) %>%
@kevindesai777
kevindesai777 / Q1code
Created October 5, 2014 09:45
Question 1 code for Striker
library('dplyr')
football = read.csv("2013-14.csv")
football = tbl_df(football)
home <- football %>%
group_by(HomeTeam) %>%
summarise(HomeWins = sum(FTHG > FTAG), HomeDraws= sum(FTHG==FTAG), HomeLoses=sum(FTHG < FTAG), GoalDifference=sum(FTHG-FTAG), RedCards=sum(HR), TargetbyTotal=sum(HST/HS), HomeCorners=sum(HC), HomeShotonTarget = sum(HST), HomeGoals=sum(FTHG)) %>%
arrange(desc(HomeWins))
away <- football %>%
@kevindesai777
kevindesai777 / Instagram API Python
Created August 10, 2014 15:19
Instagram API Python
import os
import json
import urllib
import urllib2
from instagram.client import InstagramAPI
INSTAGRAM_CLIENT_ID = ''
INSTAGRAM_CLIENT_SECRET = ''