This is a graphic comparison of Average Draft Position (“ADP”) with the ranking of player selection in the 2015 Harp draft. The intent is to illustrate useful metric of player value (ADP) with how they were selected by team in the hopes of uncovering owner selection biases and criteria.
The process of gather and cleanging the is extensive. The data comes from multiple source. It requires special cleaning techniques.
### url <- "http://games.espn.go.com/ffl/livedraftresults"
### destfile <- "./ADP"
### download.file(url, destfile)
library(XML)
library(stringr)
library(data.table)
library(ggplot2)
library(gridExtra)
Create the average draft position dataframe.
adp <- readHTMLTable("ADP", trim = TRUE, as.data.frame = TRUE, stringsAsFactors = FALSE)
adp <- adp[[1]]
adp <- adp[4:204, ]
names(adp) <- adp[1,]
adp <- adp[-1,]
rownames(adp) <- 1:nrow(adp)
adp$TEAM <- str_extract(adp$`PLAYER, TEAM`, '\\b[^,]+$')
adp$`PLAYER, TEAM` <- sub("(.*?),.*", "\\1", adp$`PLAYER, TEAM`)
names(adp)[2] <- 'PLAYER'
adp$PLAYER <- sub("[*]$", "", adp$PLAYER)
Create and clean the Harp League draft dataframe.
x <- grep("Draft Recap - Free Fantasy Football - ESPN.html", dir())
file <- dir()[x]
dft <- readHTMLTable(file, trim = TRUE, as.data.frame = TRUE, stringsAsFactors = FALSE)
dft <- lapply(3:18, function(x){subset(dft[[x]][-1,])})
dft <- rbindlist(dft)
dft <- as.data.frame(dft)
names(dft) <- c("ORDER", "PLAYER", "MANAGER")
dft$PLAYER <- gsub("\\,.*","",dft$PLAYER)
dft$PLAYER <- gsub(" D/ST D/ST", "D/ST", dft$PLAYER)
dft$PLAYER <- gsub("D/ST.+D/ST", "D/ST",dft$PLAYER)
dft$PLAYER[174] <- "Panthers D/ST"
Merge the average draft postion dataframe with the draft dataframe on PLAYER column.
df <- merge(dft, adp, by.x = "PLAYER", all = TRUE)
df$`AVG PICK`[is.na(df$`AVG PICK`)] <- 150
df$`MANAGER`[is.na(df$`MANAGER`)] <- "Undrafted"
df$ORDER <- as.numeric(df$ORDER)
df <- df[with(df, order(ORDER)),]
Download and clean the end of season rankings with total points on the season (leaders only).
espn_base_url <- "http://games.espn.go.com/ffl/leaders?&startIndex="
espn_pages <- c("0","50","100", "150", "200", "250", "300", "350", "400", "450")
espn_urls <- paste0(espn_base_url, espn_pages)
## lapply(1:length(dwn.list), function(x){download.file(url = dwn.list[[x]][1], destfile = paste0("rank", x))})
nums <- 1:10
rank_files <- paste0("rank", nums)
F.RANK <- lapply(rank_files, function(x){data.table(readHTMLTable(x, as.data.frame=TRUE, stringsAsFactors=FALSE)$playertable_0)})
RANKS <- data.frame()
for(i in 1:length(F.RANK)){
RANKS <- rbind(RANKS, F.RANK[[i]])
}
names(RANKS) <- as.character(RANKS[1,])
RANKS <- RANKS[-1,]
RANKS$`PLAYER, TEAM POS` <- sub("(.*?),.*", "\\1", RANKS$`PLAYER, TEAM POS`)
#RANKS$TEAM.POS <- str_extract(RANKS$`PLAYER, TEAM POS` , '\\b[^,]+$')
#RANKS$TEAM.POS <- sub("SSPD$", "", RANKS$TEAM.POS)
#RANKS$TEAM.POS <- sub("Q$", "", RANKS$TEAM.POS)
#RANKS$TEAM.POS <- sub("P$", "", RANKS$TEAM.POS)
#RANKS$TEAM.POS <- sub("D$", "", RANKS$TEAM.POS)
#RANKS$POS.1 <- str_sub(RANKS$TEAM.POS, 5)
names(RANKS)[1] <- 'PLAYER'
RANKS$PTS <- suppressWarnings(as.numeric(RANKS$PTS))
fix <- which(is.na(RANKS$PTS) == TRUE)
RANKS <- RANKS[!fix,]
Merge df and end of season dataframes. Perform final cleaning and coerce variables.
DFinal <- merge(df, RANKS, by.x = "PLAYER", all.x = TRUE)
DFinal <- DFinal[with(DFinal, order(ORDER)),]
DFinal <- DFinal[,c(-9, -12, -13, -17, -19, -20, -21, -23, -24, -26, -29, -30, -32, -33) ]
names(DFinal) <- c("PLAYER", "ORDER", "MANAGER", "RANK", "POS", "AVGPICK", "7DAY", "AVGVALUE", "PctOWN", "TEAM", "YDS", "TD", "INT", "RUSH", "REC", "TAR", "2PC", "FUML","PTS")
DFinal$MANAGER <- as.factor(DFinal$MANAGER)
DFinal$AVGPICK <- as.numeric(DFinal$AVGPICK)
DFinal$RANK <- as.numeric(DFinal$RANK)
DFinal$POS <- as.factor(DFinal$POS)
DFinal$TEAM <- as.factor(DFinal$TEAM)
Split DFinal into list of dataframes by MANAGER or undrafted.
TEAMS <- split(DFinal, DFinal$MANAGER)
x <- grep("Undrafted", names(TEAMS))
TEAMS[[x]] <- NULL
## [[1]]
## [[1]][[1]]
## [1] "Autodraft For The Win"
##
## [[1]][[2]]
##
## [[1]][[3]]
##
## [[1]][[4]]
## PLAYER RANK AVGPICK PTS
## [1,] "Le'Veon Bell" "2" "3.5" "83"
## [2,] "Julio Jones" "17" "17.2" "231"
## [3,] "Mike Evans" "28" "30.9" "131"
## [4,] "Melvin Gordon" "39" "40.4" "64"
## [5,] "Todd Gurley" "45" "49.9" "176"
## [6,] "Greg Olsen" "46" "50" "144"
## [7,] "Brandon Marshall" "62" "63.5" "223"
## [8,] "Tre Mason" "102" "106.1" "26"
## [9,] "Shane Vereen" "95" "101.4" "88"
## [10,] "Kendall Wright" "118" "116.7" "54"
## [11,] "Andre Williams" "144" "129.4" "28"
## [12,] "DeAngelo Williams" "162" "133.7" "179"
## [13,] "Denard Robinson" "193" "141.8" "38"
## [14,] "Cardinals D/ST" "149" "130.8" NA
## [15,] "Cody Parkey" "174" "136.5" "16"
## [16,] "Jay Cutler" "142" "128.9" "217"
##
## [[1]][[5]]
## [1] 8.58125
##
##
## [[2]]
## [[2]][[1]]
## [1] "ball hater"
##
## [[2]][[2]]
##
## [[2]][[3]]
##
## [[2]][[4]]
## PLAYER RANK AVGPICK PTS
## [1,] "Andrew Luck" "11" "12.5" "126"
## [2,] "Demaryius Thomas" "12" "13" "156"
## [3,] "Vincent Jackson" "53" "57.2" "70"
## [4,] "Carlos Hyde" "36" "36.7" "66"
## [5,] "T.J. Yeldon" "65" "66.4" "109"
## [6,] "Giovani Bernard" "66" "68.9" "119"
## [7,] "Ryan Tannehill" "94" "100.2" "245"
## [8,] "Torrey Smith" "91" "97.5" "87"
## [9,] "Ravens D/ST" "140" "128.5" NA
## [10,] "Anquan Boldin" "117" "115.8" "95"
## [11,] "David Johnson" "189" "141" "164"
## [12,] "Vernon Davis" "135" "125.5" "35"
## [13,] "Malcom Floyd" "190" "141.1" "66"
## [14,] "49ers D/ST" "160" "133.3" NA
## [15,] "Coby Fleener" "163" "133.7" "63"
## [16,] "Dan Carpenter" NA "150" "112"
##
## [[2]][[5]]
## [1] 10.04667
##
##
## [[3]]
## [[3]][[1]]
## [1] "Barefoot and Pregnant"
##
## [[3]][[2]]
##
## [[3]][[3]]
##
## [[3]][[4]]
## PLAYER RANK AVGPICK PTS
## [1,] "Rob Gronkowski" "14" "14.6" "176"
## [2,] "LeSean McCoy" "15" "14.7" "137"
## [3,] "Davante Adams" "52" "55.6" "51"
## [4,] "Tom Brady" "72" "79.7" "335"
## [5,] "Chris Ivory" "73" "80" "159"
## [6,] "Jarvis Landry" "70" "73" "154"
## [7,] "Michael Floyd" "96" "102.9" "115"
## [8,] "Bills D/ST" "78" "84.5" NA
## [9,] "Stephen Gostkowski" "89" "93.5" "168"
## [10,] "Eli Manning" "100" "104.9" "278"
## [11,] "Cody Latimer" "170" "135.5" "11"
## [12,] "Lorenzo Taliaferro" "164" "133.8" "12"
## [13,] "Owen Daniels" "122" "119" "62"
## [14,] "Jaelen Strong" NA "150" "31"
## [15,] "Reggie Bush" "166" "134" NA
## [16,] "Danny Amendola" NA "150" "74"
##
## [[3]][[5]]
## [1] 3.95
##
##
## [[4]]
## [[4]][[1]]
## [1] "Bodie's First Fantasy Week"
##
## [[4]][[2]]
##
## [[4]][[3]]
##
## [[4]][[4]]
## PLAYER RANK AVGPICK PTS
## [1,] "Marshawn Lynch" "4" "5" "66"
## [2,] "Drew Brees" "33" "33.6" "299"
## [3,] "Arian Foster" "55" "58.9" "51"
## [4,] "DeSean Jackson" "48" "52.9" "72"
## [5,] "Golden Tate" "47" "50.7" "111"
## [6,] "LeGarrette Blount" "74" "80.3" "110"
## [7,] "Travis Kelce" "54" "57.6" "109"
## [8,] "Tevin Coleman" "97" "103.7" "37"
## [9,] "Larry Fitzgerald" "86" "89.5" "164"
## [10,] "Victor Cruz" "109" "110.6" NA
## [11,] "Matt Asiata" NA "150" "13"
## [12,] "Patriots D/ST" "124" "120.4" NA
## [13,] "Terrance Williams" "151" "131.1" "96"
## [14,] "Carson Palmer" "150" "131.1" "300"
## [15,] "Rueben Randle" NA "150" "121"
## [16,] "Chandler Catanzaro" NA "150" "140"
##
## [[4]][[5]]
## [1] 0.5076923
##
##
## [[5]]
## [[5]][[1]]
## [1] "Eddie Haskels"
##
## [[5]][[2]]
##
## [[5]][[3]]
##
## [[5]][[4]]
## PLAYER RANK AVGPICK PTS
## [1,] "Eddie Lacy" "3" "3.8" "109"
## [2,] "T.Y. Hilton" "22" "24.8" "135"
## [3,] "Jimmy Graham" "26" "29.2" "69"
## [4,] "Jonathan Stewart" "42" "48.1" "139"
## [5,] "Seahawks D/ST" "58" "61.8" NA
## [6,] "Nelson Agholor" "77" "82.8" "29"
## [7,] "Matthew Stafford" "93" "99.4" "280"
## [8,] "Devonta Freeman" "110" "112.5" "230"
## [9,] "Steve Smith Sr." "99" "104.3" "82"
## [10,] "Adam Vinatieri" "103" "106.7" "121"
## [11,] "Sam Bradford" "104" "106.8" "184"
## [12,] "Knile Davis" "172" "135.8" "11"
## [13,] "Ronnie Hillman" "167" "134.5" "129"
## [14,] "Khiry Robinson" NA "150" "46"
## [15,] "Marvin Jones" "194" "142.5" "101"
## [16,] "Karlos Williams" NA "150" "109"
##
## [[5]][[5]]
## [1] 5.5
##
##
## [[6]]
## [[6]][[1]]
## [1] "Fuck this stupid game"
##
## [[6]][[2]]
##
## [[6]][[3]]
##
## [[6]][[4]]
## PLAYER RANK AVGPICK PTS
## [1,] "DeMarco Murray" "7" "10.5" "129"
## [2,] "Aaron Rodgers" "10" "11.9" "286"
## [3,] "Justin Forsett" "32" "33.4" "83"
## [4,] "Keenan Allen" "43" "48.8" "90"
## [5,] "Andre Johnson" "50" "54.6" "68"
## [6,] "Sammy Watkins" "59" "62.4" "152"
## [7,] "Marques Colston" "107" "109.6" "68"
## [8,] "Charles Johnson" "90" "93.7" "10"
## [9,] "Pierre Garcon" "146" "129.7" "108"
## [10,] "Broncos D/ST" "115" "114.4" NA
## [11,] "Zach Ertz" "105" "107" "89"
## [12,] "Darren Sproles" "139" "128.1" "94"
## [13,] "Roy Helu" NA "150" "14"
## [14,] "Justin Tucker" "154" "131.5" "139"
## [15,] "Cecil Shorts III" NA "150" "61"
## [16,] "Colin Kaepernick" "132" "123.8" "103"
##
## [[6]][[5]]
## [1] 2.114286
##
##
## [[7]]
## [[7]][[1]]
## [1] "Hoes Before Bros"
##
## [[7]][[2]]
##
## [[7]][[3]]
##
## [[7]][[4]]
## PLAYER RANK AVGPICK PTS
## [1,] "Jeremy Hill" "19" "17.6" "145"
## [2,] "Dez Bryant" "13" "13.4" "54"
## [3,] "Lamar Miller" "30" "31.9" "173"
## [4,] "Jordan Matthews" "38" "40.2" "139"
## [5,] "Jeremy Maclin" "57" "61.6" "148"
## [6,] "Ben Roethlisberger" "41" "47.7" "222"
## [7,] "Delanie Walker" "113" "113.2" "143"
## [8,] "Ameer Abdullah" "80" "85.2" "78"
## [9,] "Dolphins D/ST" "127" "122" NA
## [10,] "Tyler Lockett" "134" "125.2" "104"
## [11,] "Brian Quick" "181" "138.8" "7"
## [12,] "DeVante Parker" "153" "131.4" "64"
## [13,] "Teddy Bridgewater" "125" "120.8" "187"
## [14,] "Dion Lewis" NA "150" "77"
## [15,] "Brandon McManus" "191" "141.3" "135"
## [16,] "Austin Seferian-Jenkins" "184" "139.5" "55"
##
## [[7]][[5]]
## [1] 10.41333
##
##
## [[8]]
## [[8]][[1]]
## [1] "MR YUCK .."
##
## [[8]][[2]]
##
## [[8]][[3]]
##
## [[8]][[4]]
## PLAYER RANK AVGPICK PTS
## [1,] "Antonio Brown" "6" "7.9" "243"
## [2,] "Odell Beckham Jr." "16" "16.5" "216"
## [3,] "Emmanuel Sanders" "29" "31.7" "140"
## [4,] "Russell Wilson" "24" "27.3" "322"
## [5,] "Joique Bell" "63" "64.6" "72"
## [6,] "Rashad Jennings" "68" "72.3" "125"
## [7,] "Jordan Cameron" "81" "85.4" "50"
## [8,] "Allen Robinson" "79" "84.7" "217"
## [9,] "John Brown" "101" "106" "134"
## [10,] "Duke Johnson Jr." NA "150" "90"
## [11,] "Charles Sims" "136" "126.4" "117"
## [12,] "David Cobb" "165" "133.8" "18"
## [13,] "Jerick McKinnon" "200" "147.6" "51"
## [14,] "Daniel Herron" NA "150" "6"
## [15,] "Lions D/ST" "185" "139.7" NA
## [16,] "Matt Bryant" "197" "144.1" "70"
##
## [[8]][[5]]
## [1] 11.57143
##
##
## [[9]]
## [[9]][[1]]
## [1] "Team Manischewitz"
##
## [[9]][[2]]
##
## [[9]][[3]]
##
## [[9]][[4]]
## PLAYER RANK AVGPICK PTS
## [1,] "Matt Forte" "9" "11.2" "159"
## [2,] "Randall Cobb" "21" "23.1" "120"
## [3,] "Brandin Cooks" "34" "34.2" "162"
## [4,] "Peyton Manning" "23" "27.2" "87"
## [5,] "Andre Ellington" "56" "60.1" "52"
## [6,] "Mike Wallace" "69" "72.5" "54"
## [7,] "Isaiah Crowell" "83" "86.5" "107"
## [8,] "Dwayne Allen" "108" "110.2" "13"
## [9,] "Rams D/ST" "98" "103.9" NA
## [10,] "Devin Funchess" "119" "118.4" "70"
## [11,] "Markus Wheaton" "155" "131.5" "100"
## [12,] "Donte Moncrief" "195" "142.9" "104"
## [13,] "Steven Hauschka" "116" "114.7" "144"
## [14,] "Joe Flacco" "123" "120.3" "155"
## [15,] "Dorial Green-Beckham" "196" "144" "77"
## [16,] "Matt Jones" NA "150" "84"
##
## [[9]][[5]]
## [1] 6.953333
##
##
## [[10]]
## [[10]][[1]]
## [1] "Texas Gridiron"
##
## [[10]][[2]]
##
## [[10]][[3]]
##
## [[10]][[4]]
## PLAYER RANK AVGPICK PTS
## [1,] "Adrian Peterson" "1" "2.9" "217"
## [2,] "Alfred Morris" "31" "32" "79"
## [3,] "DeAndre Hopkins" "35" "34.9" "211"
## [4,] "Amari Cooper" "44" "49.6" "133"
## [5,] "Julian Edelman" "40" "42.5" "107"
## [6,] "Doug Martin" "76" "82.6" "187"
## [7,] "Jason Witten" "61" "63.3" "80"
## [8,] "Texans D/ST" "82" "86.2" NA
## [9,] "Philip Rivers" "106" "107.3" "277"
## [10,] "Bishop Sankey" "112" "112.9" "39"
## [11,] "Roddy White" "88" "93.1" "51"
## [12,] "Jeff Janis" NA "150" "7"
## [13,] "Terrance West" NA "150" "17"
## [14,] "Matt Prater" "192" "141.5" "116"
## [15,] "Breshad Perriman" "168" "134.8" NA
## [16,] "Nick Foles" NA "150" "90"
##
## [[10]][[5]]
## [1] 4.030769
##
##
## [[11]]
## [[11]][[1]]
## [1] "Well, fuck"
##
## [[11]][[2]]
##
## [[11]][[3]]
##
## [[11]][[4]]
## PLAYER RANK AVGPICK PTS
## [1,] "Jamaal Charles" "5" "5.2" "75"
## [2,] "Calvin Johnson" "18" "17.5" "164"
## [3,] "Alshon Jeffery" "25" "27.5" "101"
## [4,] "Joseph Randle" "51" "54.8" "60"
## [5,] "Tony Romo" "67" "69.5" "39"
## [6,] "C.J. Spiller" "71" "77.1" "39"
## [7,] "Martellus Bennett" "64" "65.3" "56"
## [8,] "Martavis Bryant" "92" "97.9" "112"
## [9,] "Percy Harvin" "175" "136.7" "26"
## [10,] "Darren McFadden" "114" "114.3" "145"
## [11,] "Jets D/ST" "126" "121.1" NA
## [12,] "Michael Crabtree" "177" "137.4" "139"
## [13,] "Dan Bailey" "179" "138.1" "129"
## [14,] "Doug Baldwin" "176" "136.9" "184"
## [15,] "Cole Beasley" NA "150" "73"
## [16,] "Cameron Artis-Payne" NA "150" "25"
##
## [[11]][[5]]
## [1] 10.05
##
##
## [[12]]
## [[12]][[1]]
## [1] "win or win not thr is no goal"
##
## [[12]][[2]]
##
## [[12]][[3]]
##
## [[12]][[4]]
## PLAYER RANK AVGPICK PTS
## [1,] "C.J. Anderson" "8" "10.8" "103"
## [2,] "A.J. Green" "20" "21.7" "179"
## [3,] "Mark Ingram" "27" "29.2" "143"
## [4,] "Frank Gore" "37" "39.9" "147"
## [5,] "Latavius Murray" "49" "53.6" "148"
## [6,] "Matt Ryan" "60" "63" "224"
## [7,] "Eric Decker" "84" "87.2" "166"
## [8,] "Ryan Mathews" "87" "89.5" "95"
## [9,] "Danny Woodhead" "120" "118.5" "149"
## [10,] "Alfred Blue" "111" "112.7" "85"
## [11,] "Cam Newton" "75" "81.2" "373"
## [12,] "Eddie Royal" "161" "133.4" "26"
## [13,] "Larry Donnell" "173" "136" "30"
## [14,] "Antonio Gates" "130" "122.9" "88"
## [15,] "Panthers D/ST" "178" "138" NA
## [16,] "Mason Crosby" "187" "140.2" "120"
##
## [[12]][[5]]
## [1] 8.075