1

data(cars)
median(cars[,1])
## [1] 15

2

url <- "https://min-api.cryptocompare.com/data/v2/histoday?fsym=BTC&tsym=USD&limit=99"

btc_json <- fromJSON(url)

btc_data <- btc_json$Data$Data

max_close <- max(btc_data$close, na.rm = TRUE)
max_close
## [1] 96945.09

3 - Does Paying Your Quarterback Lead to Winning? An Analysis of NFL Team QB Spending and Success

qb <- read.csv("qb_spending_2021_2025.csv")
perf <- read.csv("team_performance_2021_2025.csv")

nfl_data <- merge(qb, perf, by = c("Team", "Season"))
summary(nfl_data) # avg qb : 19773107 avg wins: 8.469
##      Team               Season           QB                Wins       
##  Length:160         Min.   :2021   Min.   : 2622691   Min.   : 2.000  
##  Class :character   1st Qu.:2022   1st Qu.:10250705   1st Qu.: 6.000  
##  Mode  :character   Median :2023   Median :16055578   Median : 9.000  
##                     Mean   :2023   Mean   :19773107   Mean   : 8.469  
##                     3rd Qu.:2024   3rd Qu.:28225764   3rd Qu.:11.000  
##                     Max.   :2025   Max.   :52856419   Max.   :15.000  
##    Points_For   
##  Min.   :236.0  
##  1st Qu.:330.0  
##  Median :376.0  
##  Mean   :382.4  
##  3rd Qu.:441.8  
##  Max.   :564.0

Question 1: Is team quarterback cap hit correlated with total regular season wins?

cor(nfl_data$QB, nfl_data$Wins) # 0.106
## [1] 0.1059842
ggplot(nfl_data, aes(x = QB, y = Wins)) +
  geom_jitter(alpha = 0.6, color = "navy", width = 0, height = 0.2) +
  geom_smooth(method = "lm", se = TRUE, color = "red") +
  scale_x_continuous(labels = scales::dollar) +
  labs(
    title = "QB Spending vs Team Wins (2021–2025)",
    x = "QB Cap Hit",
    y = "Regular Season Wins"
  ) +
  theme_minimal()

There is a very weak positive relationship between QB spending and team wins, suggesting that higher spending does not strongly predict better performance.

Question 2: Do teams in the top quartile of quarterback spending win significantly more games than teams in the bottom quartile?

nfl_data$spending_quartile <- ntile(nfl_data$QB, 4)

table(nfl_data$spending_quartile)
## 
##  1  2  3  4 
## 40 40 40 40
aggregate(Wins ~ spending_quartile, data = nfl_data, mean)
##   spending_quartile  Wins
## 1                 1 7.350
## 2                 2 8.825
## 3                 3 8.700
## 4                 4 9.000
ggplot(nfl_data, aes(x = factor(spending_quartile), y = Wins)) +
  geom_boxplot(fill = "lightblue") +
  labs(
    title = "Wins by QB Spending Quartile",
    x = "QB Spending Quartile (1 = Lowest, 4 = Highest)",
    y = "Regular Season Wins"
  ) +
  theme_minimal()

High QB spenders win about 1.6 more games than low spenders on average.

Question 3: Is quarterback spending more strongly correlated with offensive production (points scored) than with total wins?

cor(nfl_data$QB, nfl_data$Points_For)
## [1] 0.1591055
ggplot(nfl_data, aes(x = QB, y = Points_For)) +
  geom_jitter(alpha = 0.6, color = "darkgreen", width = 0, height = 5) +
  geom_smooth(method = "lm", se = TRUE, color = "red") +
  scale_x_continuous(labels = scales::dollar) +
  labs(
    title = "QB Spending vs Points Scored (2021–2025)",
    x = "QB Cap Hit",
    y = "Points Scored"
  ) +
  theme_minimal()

So QB spending is more strongly correlated with offensive production than with total wins, but still weak overall.