Synopis

We are going to examine the number of wins for the 4 NFL Teams in the AFC Central Division, since 1990

The 4 teams are the Pittsburgh Steelers, the Baltimore Ravens, the Cincinati Bengals and the Cleveland Browns.

Note: The Ravens were not in existance until 1996

Note: The Browns were not in existance 1996-1998

install.packages(“plotly”) # to create interactive plots install.packages(“readxl”)

library(plotly)
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(tidyr) # To use Gather Function

Read the Dataset

library("readxl")
Wins<- read_excel("Wins AFC Central.xlsx")

Create a Dataframe , View the Data and Gather the columns

AFC_Cent_Wins <- as.data.frame(Wins) 
head(AFC_Cent_Wins, 30)
##    Year Steelers Ravens Bengals Browns
## 1  2019        8     14       2      6
## 2  2018        9     10       6      7
## 3  2017       13      9       7      0
## 4  2016       11      8       6      1
## 5  2015       10      5      12      3
## 6  2014       11     10      10      7
## 7  2013        8      8      11      4
## 8  2012        8     10      10      5
## 9  2011       12     12       9      4
## 10 2010       12     12       4      5
## 11 2009        9      9      10      5
## 12 2008       12     11       4      4
## 13 2007       10      5       7     10
## 14 2006        8     13       8      4
## 15 2005       11      6      11      6
## 16 2004       15      9       8      4
## 17 2003        6     10       8      5
## 18 2002       10      7       2      9
## 19 2001       13     10       6      7
## 20 2000        9     12       4      3
## 21 1999        6      8       4      2
## 22 1998        7      6       3     NA
## 23 1997       11      6       7     NA
## 24 1996       10      4       8     NA
## 25 1995       11     NA       7      5
## 26 1994       12     NA       3     11
## 27 1993        9     NA       3      7
## 28 1992       11     NA       5      7
## 29 1991        7     NA       3      6
## 30 1990        9     NA       9      3
AFC_Cent_Wins <- gather(AFC_Cent_Wins,
                   key = "Team",
                   value = "Wins",
                   -Year)

Plot the number of wins for each team in an interactive graph. The lines are color-coded with the teams colors.

colors <- c("orangered", "brown4", "purple4", "goldenrod1")
plot_ly(AFC_Cent_Wins, x = ~Year) %>%
  add_lines(y = ~Wins, color = ~Team, colors = colors)
## Warning: `arrange_()` is deprecated as of dplyr 0.7.0.
## Please use `arrange()` instead.
## See vignette('programming') for more help
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.