#Installing and reading json files into R
library(rjson)
## Warning: package 'rjson' was built under R version 4.0.5
F1_Virtual_Safety_Car_Estimates <- fromJSON(file = "~/Data Science Master Program/Spring 2022/Data Analytics I/virtual_safety_car_estimates.json")
print(F1_Virtual_Safety_Car_Estimates)
## $`2015 Belgian Grand Prix`
## [1] 20 21
##
## $`2015 British Grand Prix`
## [1] 32 33 34
##
## $`2015 Hungarian Grand Prix`
## [1] 41 42
##
## $`2015 Monaco Grand Prix`
## [1] 62 63 64
##
## $`2015 Singapore Grand Prix`
## [1] 36
##
## $`2016 British Grand Prix`
## [1] 17 18
##
## $`2016 Monaco Grand Prix`
## [1] 30 31 34 35 49 50 66 67 68
##
## $`2016 United States Grand Prix`
## [1] 29 30 31
##
## $`2017 Mexican Grand Prix`
## [1] 31 32
##
## $`2017 Spanish Grand Prix`
## [1] 32 33 34 35 36
##
## $`2018 Austrian Grand Prix`
## [1] 14 15
##
## $`2018 French Grand Prix`
## [1] 50 51
##
## $`2018 Hungarian Grand Prix`
## [1] 5 6 49 50 51
##
## $`2018 Monaco Grand Prix`
## [1] 71 72 73
##
## $`2018 Spanish Grand Prix`
## [1] 39 40 41
##
## $`2019 Azerbaijan Grand Prix`
## [1] 38 39 40
##
## $`2019 French Grand Prix`
## [1] 48 49
##
## $`2019 German Grand Prix`
## [1] 14 15
##
## $`2019 Italian Grand Prix`
## [1] 27 28 29 30
##
## $`2020 Russian Grand Prix`
## [1] 41 42
##
## $`2020 Sakhir Grand Prix`
## [1] 53 54 55
##
## $`2020 Turkish Grand Prix`
## [1] 12 13
##
## $`2021 Abu Dhabi Grand Prix`
## [1] 34 35 36
##
## $`2021 Saudi Arabian Grand Prix`
## [1] 22 23 26 27 34 35
##
## $`2016 Malaysian Grand Prix`
## [1] 8 9 39 40 41
##
## $`2017 Japanese Grand Prix`
## [1] 46 47 48
##
## $`2018 Japanese Grand Prix`
## [1] 39 40
##
## $`2018 United States Grand Prix`
## [1] 9 10 11
##
## $`2018 Mexican Grand Prix`
## [1] 29 30 31 59 60 61 62
##
## $`2021 Qatar Grand Prix`
## [1] 53 54 55
##
## $`2021 United States Grand Prix`
## [1] 26 27
#Reading csv files into R
Beer_Ratings <- read.csv("~/Data Science Master Program/Spring 2022/Data Analytics I/beer_profile_ratings.csv")
library(utils)
head(Beer_Ratings)
## Name Style
## 1 Amber Altbier
## 2 Double Bag Altbier
## 3 Long Trail Ale Altbier
## 4 Doppelsticke Altbier
## 5 Sleigh'r Dark Doüble Alt Ale Altbier
## 6 Sticke Altbier
## Brewery
## 1 Alaskan Brewing Co.
## 2 Long Trail Brewing Co.
## 3 Long Trail Brewing Co.
## 4 Uerige Obergärige Hausbrauerei GmbH / Zum Uerige
## 5 Ninkasi Brewing Company
## 6 Uerige Obergärige Hausbrauerei GmbH / Zum Uerige
## Beer.Name..Full.
## 1 Alaskan Brewing Co. Alaskan Amber
## 2 Long Trail Brewing Co. Double Bag
## 3 Long Trail Brewing Co. Long Trail Ale
## 4 Uerige Obergärige Hausbrauerei GmbH / Zum Uerige Uerige Doppelsticke
## 5 Ninkasi Brewing Company Sleigh'r Dark Doüble Alt Ale
## 6 Uerige Obergärige Hausbrauerei GmbH / Zum Uerige Uerige Sticke
## Description
## 1 Notes:Richly malty and long on the palate, with just enough hop backing to make this beautiful amber colored "alt" style beer notably well balanced.\\t
## 2 Notes:This malty, full-bodied double alt is also known as “Stickebier” – German slang for “secret brew”. Long Trail Double Bag was originally offered only in our brewery taproom as a special treat to our visitors. With an alcohol content of 7.2%, please indulge in moderation. The Long Trail Brewing Company is proud to have Double Bag named Malt Advocate’s “Beer of the Year” in 2001. Malt Advocate is a national magazine devoted to “expanding the boundaries of fine drinks”. Their panel of judges likes to keep things simple, and therefore of thousands of eligible competitors they award only two categories: “Imported” and “Domestic”. It is a great honor to receive this recognition.33 IBU\\t
## 3 Notes:Long Trail Ale is a full-bodied amber ale modeled after the “Alt-biers” of Düsseldorf, Germany. Our top fermenting yeast and cold finishing temperature result in a complex, yet clean, full flavor. Originally introduced in November of 1989, Long Trail Ale beer quickly became, and remains, the largest selling craft-brew in Vermont. It is a multiple medal winner at the Great American Beer Festival.25 IBU\\t
## 4 Notes:
## 5 Notes:Called 'Dark Double Alt' on the label.Seize the season with Sleigh'r. Layers of deeply toasted malt are balanced by just enough hop bitterness to make it deceivingly drinkable. Paired with a dry finish, Sleigh’r is anything but your typical winter brew.An Alt ferments with Ale yeast at colder lagering temperatures. This effect gives Alts a more refined, crisp lager-like flavor than traditional ales. The Alt has been “Ninkasified” raising the ABV and IBUs. Sleigh'r has a deep, toasted malt flavor that finishes dry and balanced.50 IBU\\t
## 6 Notes:
## ABV Min.IBU Max.IBU Astringency Body Alcohol Bitter Sweet Sour Salty Fruits
## 1 5.3 25 50 13 32 9 47 74 33 0 33
## 2 7.2 25 50 12 57 18 33 55 16 0 24
## 3 5.0 25 50 14 37 6 42 43 11 0 10
## 4 8.5 25 50 13 55 31 47 101 18 1 49
## 5 7.2 25 50 25 51 26 44 45 9 1 11
## 6 6.0 25 50 22 45 13 46 62 25 1 34
## Hoppy Spices Malty review_aroma review_appearance review_palate review_taste
## 1 57 8 111 3.498994 3.636821 3.556338 3.643863
## 2 35 12 84 3.798337 3.846154 3.904366 4.024948
## 3 54 4 62 3.409814 3.667109 3.600796 3.631300
## 4 40 16 119 4.148098 4.033967 4.150815 4.205163
## 5 51 20 95 3.625000 3.973958 3.734375 3.765625
## 6 60 4 103 4.007937 4.007937 4.087302 4.192063
## review_overall number_of_reviews
## 1 3.847082 497
## 2 4.034304 481
## 3 3.830239 377
## 4 4.005435 368
## 5 3.817708 96
## 6 4.230159 315
options(scipen = 9999) #According to NFL Fast R guide, this perfer not to display numbers in scientific notation
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.0.5
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5 v purrr 0.3.4
## v tibble 3.1.6 v dplyr 1.0.8
## v tidyr 1.2.0 v stringr 1.4.0
## v readr 2.1.2 v forcats 0.5.1
## Warning: package 'ggplot2' was built under R version 4.0.5
## Warning: package 'tibble' was built under R version 4.0.5
## Warning: package 'tidyr' was built under R version 4.0.5
## Warning: package 'readr' was built under R version 4.0.5
## Warning: package 'purrr' was built under R version 4.0.5
## Warning: package 'dplyr' was built under R version 4.0.5
## Warning: package 'stringr' was built under R version 4.0.5
## Warning: package 'forcats' was built under R version 4.0.5
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(nflfastR)
## Warning: package 'nflfastR' was built under R version 4.0.5
#Loading in our data from R
pratice_data <- load_pbp(2021)
#Lets Filter our Data, want to get Final Scores of regulation from Week 1
win_loss_data <- pratice_data %>%
filter(season_type == 'REG' & week == 1 & qtr == 4 ) %>%
select(home_team, home_score, away_team, away_score, result)
win_loss_data <- unique(win_loss_data) #Get unique values of all datasets
summary(win_loss_data) #Get Descriptive statistics of dataset
## home_team home_score away_team away_score
## Length:16 Min. : 6.00 Length:16 Min. : 3.00
## Class :character 1st Qu.:16.00 Class :character 1st Qu.:19.25
## Mode :character Median :23.00 Mode :character Median :25.50
## Mean :23.81 Mean :24.19
## 3rd Qu.:33.00 3rd Qu.:29.00
## Max. :38.00 Max. :41.00
## result
## Min. :-26.000
## 1st Qu.: -9.000
## Median : 0.500
## Mean : -0.375
## 3rd Qu.: 5.250
## Max. : 35.000
#Lets visualize our distributions
hist(win_loss_data$home_score) #histogram of home scores

hist(win_loss_data$away_score) #histogram of away scores

#Home Score Density Plots
library(ggplot2)
home_score_density_plot <- ggplot(win_loss_data, aes(x= home_score)) +
geom_density()
home_score_density_plot

#Away Score Density Plots
away_score_density_plot <- ggplot(win_loss_data, aes(x= away_score)) +
geom_density()
away_score_density_plot
