Importing the NFL Dataset, Checking variables.
library(knitr)
library(plyr)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:plyr':
##
## arrange, count, desc, failwith, id, mutate, rename, summarise,
## summarize
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
#library(devtools)
library(RCurl)
## Loading required package: bitops
#t1 <- read.csv(file = "nfl-elo/nfl_elo_latest.csv")
#t2 <- read.csv(file = "nfl-elo/nfl_elo.csv")
url <- getURL("https://raw.githubusercontent.com/Foxxenn/Week-1-Assignment/main/nfl-elo/nfl_elo.csv")
t4 <-data.frame(read.csv(text= url))
head(t4)
Selecting from only 1990 to present and rows with Dak Prescott
# dplyr syntax
t4_sub <- t4 %>% filter(season>1990, qb1 == "Dak Prescott")
head(t4_sub)
# plyr syntax
#t4_sub <- subset(t4, season > 1990 & qb1 == "Dak Prescott")
#head(t4_sub)
Select a subset by row.
qbs <- t4 %>% filter(season>1990)
qb_1990 <- qbs[, c("season","qb1","total_rating")]
head(qb_1990)
qb_1990_wo_Nas <- qb_1990[complete.cases(qb_1990),]
head(qb_1990_wo_Nas)
Filtering to get Tom Brady
tom_brady <-qb_1990_wo_Nas_Names %>% filter( QuaterBack == "Tom Brady")
Bar Plots
Tom Brady’s total ratings for 2021 annd 2022 (he only has data for
these years)
barplot(table(tom_brady$total_rating), main = "Tom Brady")
