# excel file
data <- read_excel("../00_data/MyData.xlsx")
data
## # A tibble: 638 × 15
##    team        team_…¹  year  wins  loss point…² point…³ point…⁴ margi…⁵ stren…⁶
##    <chr>       <chr>   <dbl> <dbl> <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
##  1 Miami       Dolphi…  2000    11     5     323     226      97     6.1     1  
##  2 Indianapol… Colts    2000    10     6     429     326     103     6.4     1.5
##  3 New York    Jets     2000     9     7     321     321       0     0       3.5
##  4 Buffalo     Bills    2000     8     8     315     350     -35    -2.2     2.2
##  5 New England Patrio…  2000     5    11     276     338     -62    -3.9     1.4
##  6 Tennessee   Titans   2000    13     3     346     191     155     9.7    -1.3
##  7 Baltimore   Ravens   2000    12     4     333     165     168    10.5    -2.5
##  8 Pittsburgh  Steele…  2000     9     7     321     255      66     4.1    -0.2
##  9 Jacksonvil… Jaguars  2000     7     9     367     327      40     2.5    -1.4
## 10 Cincinnati  Bengals  2000     4    12     185     359    -174   -10.9     0.4
## # … with 628 more rows, 5 more variables: simple_rating <dbl>,
## #   offensive_ranking <dbl>, defensive_ranking <dbl>, playoffs <chr>,
## #   sb_winner <chr>, and abbreviated variable names ¹​team_name, ²​points_for,
## #   ³​points_against, ⁴​points_differential, ⁵​margin_of_victory,
## #   ⁶​strength_of_schedule

Introduction

Questions

Variation

Visualizing distributions

ggplot(data = data) +
    geom_boxplot(mapping = aes(x = sb_winner))

ggplot(data = data) +
    geom_histogram(mapping = aes (x = wins))

ggplot(data = data, mapping = aes(x = wins, colour = team_name)) + geom_freqpoly()

Typical values

data %>%
    
    # Filter out less than 10 wins
    filter(wins < 10) %>%
    
    # Plot
    ggplot(aes(x = wins)) +
    geom_histogram(binwidth = 0.5)

Unusual values

data %>%
    
    ggplot(aes(x = wins)) +
    geom_histogram() +
    coord_cartesian(ylim = c(0,50))

Missing Values

Covariation

A categorical and continuous variable

Two categorical variables

Two continous variables

Patterns and models