library(ggplot2)
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 3.4.4
## -- Attaching packages ----------------- tidyverse 1.2.1 --
## v tibble 1.4.2 v purrr 0.2.5
## v tidyr 0.8.1 v dplyr 0.7.6
## v readr 1.1.1 v stringr 1.2.0
## v tibble 1.4.2 v forcats 0.2.0
## Warning: package 'tibble' was built under R version 3.4.4
## Warning: package 'tidyr' was built under R version 3.4.4
## Warning: package 'purrr' was built under R version 3.4.4
## Warning: package 'dplyr' was built under R version 3.4.4
## -- Conflicts -------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(dplyr)
fights <- read_csv("C:/Users/Trevor/Documents/School/_previous/RStudio/ufc/Fights_Updated.csv")
## Warning: Missing column names filled in: 'X1' [1]
## Parsed with column specification:
## cols(
## X1 = col_integer(),
## Event_Name = col_character(),
## Match = col_integer(),
## Fighter1 = col_character(),
## Fighter2 = col_character(),
## Method = col_character(),
## Method_D = col_character(),
## Round = col_integer(),
## Time = col_time(format = ""),
## Referee = col_character(),
## Fighter1_url = col_character(),
## Fighter2_url = col_character(),
## Event_id = col_integer(),
## Date = col_character(),
## Location = col_character()
## )
## Warning in rbind(names(probs), probs_f): number of columns of result is not
## a multiple of vector length (arg 2)
## Warning: 1 parsing failure.
## row # A tibble: 1 x 5 col row col expected actual file expected <int> <chr> <chr> <chr> <chr> actual 1 1379 Time "time like~ N/A 'C:/Users/Trevor/Documents/School/_previ~ file # A tibble: 1 x 5
summary(fights)
## X1 Event_Name Match Fighter1
## Min. : 1 Length:4058 Min. : 1.000 Length:4058
## 1st Qu.:1015 Class :character 1st Qu.: 3.000 Class :character
## Median :2030 Mode :character Median : 6.000 Mode :character
## Mean :2030 Mean : 5.859
## 3rd Qu.:3044 3rd Qu.: 8.000
## Max. :4058 Max. :15.000
## Fighter2 Method Method_D Round
## Length:4058 Length:4058 Length:4058 Min. :1.000
## Class :character Class :character Class :character 1st Qu.:1.000
## Mode :character Mode :character Mode :character Median :3.000
## Mean :2.234
## 3rd Qu.:3.000
## Max. :5.000
## Time Referee Fighter1_url
## Length:4058 Length:4058 Length:4058
## Class1:hms Class :character Class :character
## Class2:difftime Mode :character Mode :character
## Mode :numeric
##
##
## Fighter2_url Event_id Date Location
## Length:4058 Min. : 7 Length:4058 Length:4058
## Class :character 1st Qu.: 8188 Class :character Class :character
## Mode :character Median :21037 Mode :character Mode :character
## Mean :24102
## 3rd Qu.:39915
## Max. :56247
glimpse(fights)
## Observations: 4,058
## Variables: 15
## $ X1 <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15...
## $ Event_Name <chr> "UFC - The Ultimate Fighter 1 Finale", "UFC - The...
## $ Match <int> 8, 7, 6, 5, 4, 3, 2, 1, 9, 9, 8, 7, 6, 5, 4, 3, 2...
## $ Fighter1 <chr> "Forrest Griffinwin", "Diego Sanchezwin", "Sam Ho...
## $ Fighter2 <chr> "Stephan Bonnarloss", "Kenny Florianloss", "Bobby...
## $ Method <chr> "Decision", "TKO", "Decision", "TKO", "KO", "TKO"...
## $ Method_D <chr> "Unanimous", "Punch", "Unanimous", "Punch", "Punc...
## $ Round <int> 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2, 3, 3, 3, 3...
## $ Time <time> 05:00:00, 02:49:00, 05:00:00, 01:35:00, 04:21:00...
## $ Referee <chr> "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", ...
## $ Fighter1_url <chr> "/fighter/Forrest-Griffin-3526", "/fighter/Diego-...
## $ Fighter2_url <chr> "/fighter/Stephan-Bonnar-3014", "/fighter/Kenny-F...
## $ Event_id <int> 2971, 2971, 2971, 2971, 2971, 2971, 2971, 2971, 2...
## $ Date <chr> "4/9/2005", "4/9/2005", "4/9/2005", "4/9/2005", "...
## $ Location <chr> "Cox Pavilion, Las Vegas, Nevada, United States",...
X1 looks to just be a total count of all fights
Each fighter has either a “win” or “loss” added to the end of their name
“Method_D” goes into further detail of that method
table(fights$Method)
##
## Decision DQ Draw
## 1702 12 27
## KO No Contest No Decision
## 475 40 2
## Submission Technical Decision Technical Submission
## 859 3 70
## TKO
## 868
table(fights$Method_D)
##
## Accidental Clash of Heads
## 1
## Accidental Eye Poke
## 5
## Accidental Foul
## 1
## Accidental Head-butt
## 1
## Achilles Hold
## 1
## Achilles Lock
## 6
## Anaconda Choke
## 13
## Ankle Injury
## 2
## Arm-Triangle Choke
## 48
## Arm Injury
## 2
## Armbar
## 101
## Armlock
## 10
## Body Kick and Punch
## 3
## Body Lock
## 1
## Body Triangle
## 1
## Both Fighters TKO'd
## 1
## Brabo Choke
## 21
## Bulldog Choke
## 4
## Calf Slicer
## 1
## Chin to the Eye
## 1
## Choke
## 5
## Corner Stoppage
## 14
## Crucifix Choke
## 1
## Cut
## 14
## Decision
## 3
## Dislocated Shoulder
## 1
## Doctor Stoppage
## 44
## Elbow
## 44
## Elbow to Back of Head
## 1
## Elbow to the Body
## 1
## Esophagus Injury
## 1
## Exhaustion
## 1
## Eye Injury
## 1
## Ezekiel Choke
## 1
## Fatigue
## 1
## Finger Injury
## 1
## Flying Head Kick and Punch
## 1
## Flying Knee
## 8
## Flying Punch and Knee
## 6
## Flying Triangle Choke
## 1
## Forearm Choke
## 1
## Front Choke
## 1
## Front Kick
## 1
## Front Kick and Punch
## 4
## Guillotine Choke
## 168
## Hand Injury
## 1
## Head Kick
## 30
## Head Kick and Knee
## 1
## Head Kick and Punch
## 30
## Headbutts
## 1
## Heel Hook
## 14
## Hook Kick and Punch
## 1
## Illegal Downward Elbow
## 1
## Illegal Knee to the Head
## 1
## Illegal Upkick
## 2
## Injury
## 3
## Inside Shoulder Lock
## 1
## Inverted Heel Hook
## 1
## Inverted Triangle Kimura
## 2
## Japanese Necktie
## 1
## Jaw Injury
## 2
## Keylock
## 5
## Kick to the Body
## 6
## Kick to the Body and Elbow
## 1
## Kick to the Body and Punch
## 8
## Kicking a Downed Opponent
## 1
## Kicking with Shoes
## 1
## Kimura
## 29
## Knee
## 31
## Knee and Body Kick
## 1
## Knee and Elbow
## 2
## Knee Injury
## 6
## Knee to Head of Grounded Fighter
## 4
## Knee to the Body
## 8
## Knee to the Body and Punch
## 8
## Kneebar
## 11
## Lapel Choke
## 3
## Leg Injury
## 6
## Leg Kick
## 7
## Lentz Struck by Illegal Knee
## 1
## Majority
## 39
## Neck Crank
## 12
## Neck Injury
## 2
## No Contest
## 1
## No Contest- Caceres Failed Drug TestHerb Dean
## 1
## No Contest- Hoffman Failed Drug Test
## 1
## No Contest- Overturned by CommissionHerb Dean
## 1
## No Contest- Overturned by State CommissionN/A
## 1
## No Contest- Premature StoppageN/A
## 1
## No ContestOtto Torriero
## 1
## North-South Choke
## 3
## Omoplata
## 1
## Overturned by CABMMA
## 2
## Overturned by CABMMA - Accidental Clash of Heads
## 1
## Overturned by Commission
## 6
## Overturned by CSAC
## 1
## Overturned by NAC
## 2
## Overturned by Nevada Athletic Commission
## 2
## Overturned by NSAC
## 2
## Overturned by NSBA
## 1
## Overturned by Promoter
## 3
## Overturned by TDLR
## 1
## Peruvian Necktie
## 1
## Pillory Choke
## 1
## Position
## 2
## Punch
## 928
## Punch and Elbow
## 51
## Punch and Elbow to the Body
## 1
## Punch and Head Kick
## 2
## Punch and Knee
## 48
## Punch to Back of Head
## 2
## Punch to the Body
## 7
## Rear-Naked Choke
## 313
## Repeated Fouls
## 1
## Retirement
## 6
## Reverse Armbar
## 1
## Reverse Bulldog Choke
## 1
## Reverse Triangle Armbar
## 1
## Rib Injury
## 2
## Sakara Kicked in Groin
## 1
## Shoulder Choke
## 3
## Shoulder Injury
## 2
## Side Kick and Punch
## 1
## Slam
## 7
## Slam and Punch
## 2
## Smother Choke
## 1
## Spinning Back-Kick
## 1
## Spinning Back-Kick and Punch
## 3
## Spinning Back Elbow
## 1
## Spinning Back Fist
## 5
## Spinning Heel Kick and Punch
## 1
## Spinning Hook Kick
## 2
## Spinning Wheel Kick
## 2
## Split
## 362
## Straight Armbar
## 7
## Strikes
## 11
## Submission to Heel Strikes
## 1
## Superman Punch
## 3
## Suplex and Punch
## 2
## Thumb Injury
## 1
## Tibau Failed Drug Test, Overturned by CABMMA
## 1
## Toe Hold
## 1
## Triangle Armbar
## 11
## Triangle Choke
## 58
## Triangle Kimura
## 1
## Twister
## 1
## Unanimous
## 1315
## Upkick and Punch
## 1
## Wheel Kick and Punch
## 1
ggplot(fights, aes(x = Method)) +
geom_bar()
methWin <- fights %>%
group_by(Method) %>%
summarize(N = n()) %>%
mutate(freq = N / sum(N),
pct = round((freq*100), 0))
## Warning: package 'bindrcpp' was built under R version 3.4.4
methWin
ggplot(methWin, aes(x = reorder(Method, -N), y = N)) +
geom_col() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
ggplot(fights, aes(x = Method_D)) +
geom_bar() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
methWin2 <- fights %>%
group_by(Method, Method_D) %>%
summarize(N = n()) %>%
mutate(freq = N / sum(N),
pct = round((freq*100), 0))
ggplot(methWin2, aes(x = reorder(Method_D, -N), y = N)) +
geom_col() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
methWin2
methWin3 <- fights %>%
group_by(Method_D, Method) %>%
summarize(N = n()) %>%
mutate(freq = N / sum(N),
pct = round((freq*100), 0)) %>%
filter(N >= 10)
methWin3
ggplot(methWin3, aes(x = reorder(Method_D, -N), y = N, fill = Method)) +
geom_col() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
ggplot(methWin3, aes(x = reorder(Method_D, -N), y = N, fill = Method)) +
geom_col() +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
scale_y_log10()
fights2 <- read_csv("C:/Users/Trevor/Documents/School/_previous/RStudio/ufc/Fights_Updated.csv")
## Warning: Missing column names filled in: 'X1' [1]
## Parsed with column specification:
## cols(
## X1 = col_integer(),
## Event_Name = col_character(),
## Match = col_integer(),
## Fighter1 = col_character(),
## Fighter2 = col_character(),
## Method = col_character(),
## Method_D = col_character(),
## Round = col_integer(),
## Time = col_time(format = ""),
## Referee = col_character(),
## Fighter1_url = col_character(),
## Fighter2_url = col_character(),
## Event_id = col_integer(),
## Date = col_character(),
## Location = col_character()
## )
## Warning in rbind(names(probs), probs_f): number of columns of result is not
## a multiple of vector length (arg 2)
## Warning: 1 parsing failure.
## row # A tibble: 1 x 5 col row col expected actual file expected <int> <chr> <chr> <chr> <chr> actual 1 1379 Time "time like~ N/A 'C:/Users/Trevor/Documents/School/_previ~ file # A tibble: 1 x 5
fights2$Date <- as.Date(fights2$Date, format = "%m/%d/%Y")
ggplot(fights2, aes(x = Date, y = Method, color = Method)) +
geom_point()
fights3 <- fights2 %>%
mutate(Year = format(Date, "%Y"))
head(fights3)
ggplot(fights3, aes(x = Year, fill = Method)) +
geom_bar(aes(position = "fill")) +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
## Warning: Ignoring unknown aesthetics: position
fights4 <- fights3 %>%
group_by(Year, Method) %>%
summarize(N = n()) %>%
mutate(freq = N / sum(N),
pct = round((freq*100), 0))
fights4
ggplot(fights4, aes(x = Year, y = pct, colour = Method)) +
geom_point() +
geom_smooth(se = FALSE, method = "lm") +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
fights4$Year <- as.Date(fights4$Year, format = "%Y")
ggplot(fights4, aes(x = Year, y = pct, colour = Method)) +
geom_point() +
geom_smooth(se = FALSE, method = "lm") +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
ggplot(fights4, aes(x = Year, y = pct, colour = Method)) +
geom_point() +
geom_smooth(se = FALSE, method = "lm") +
theme(axis.text.x = element_text(angle = 90, hjust = 1), legend.position="none") +
facet_wrap(~Method, ncol = 5)