library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.2.1 ✔ readr 2.2.0
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.3 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readxl)
stadium <-read.csv("us_sportsvenues1909_2027.csv")
stadium_clean <- drop_na(stadium)
cor(stadium_clean$publiccost2020, stadium_clean$year)
## [1] 0.4635746
stadium_clean$venuename <- NULL
stadium_clean$teams <- NULL
stadium_clean$source <- NULL
cor(stadium_clean)
## year totalcost publiccost totalcost2020 publiccost2020
## year 1.00000000 0.4953015 0.5441178 0.4972194 0.4635746
## totalcost 0.49530152 1.0000000 0.4923980 0.9559648 0.3567677
## publiccost 0.54411779 0.4923980 1.0000000 0.4869939 0.8750414
## totalcost2020 0.49721945 0.9559648 0.4869939 1.0000000 0.4671439
## publiccost2020 0.46357461 0.3567677 0.8750414 0.4671439 1.0000000
## pubpct100 0.08390035 -0.1908186 0.1815931 -0.1605465 0.3926171
## stadium -0.12087009 0.1483950 0.2389532 0.1872855 0.3116844
## arena 0.12087009 -0.1483950 -0.2389532 -0.1872855 -0.3116844
## pubpct100 stadium arena
## year 0.08390035 -0.12087009 0.12087009
## totalcost -0.19081863 0.14839503 -0.14839503
## publiccost 0.18159312 0.23895325 -0.23895325
## totalcost2020 -0.16054651 0.18728547 -0.18728547
## publiccost2020 0.39261708 0.31168443 -0.31168443
## pubpct100 1.00000000 0.09321689 -0.09321689
## stadium 0.09321689 1.00000000 -1.00000000
## arena -0.09321689 -1.00000000 1.00000000
pairs(~year+totalcost+publiccost+publiccost2020+totalcost2020+pubpct100+stadium+arena, data=stadium_clean)
cor.test(stadium_clean$year,stadium_clean$publiccost, meathod = "pearson")
##
## Pearson's product-moment correlation
##
## data: stadium_clean$year and stadium_clean$publiccost
## t = 9.0562, df = 195, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.4376089 0.6355688
## sample estimates:
## cor
## 0.5441178
With a pearson test it helps to match the linear progression of years compared to the public cost of stadiums that are being built.There is a slight correlation between the two meaning that as the years progress local governments have started to increase the amount of public funding towards stadiums.