library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.0 ✔ readr 2.1.5
## ✔ ggplot2 3.5.1 ✔ stringr 1.5.1
## ✔ lubridate 1.9.3 ✔ tibble 3.2.1
## ✔ purrr 1.0.2 ✔ tidyr 1.3.1
## ── 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)
Austin_crash_report <- read.csv("~/PAD 6833/Homework 5/Austin crash report.csv")
cor.test(Austin_crash_report$motor_vehicle_death_count,Austin_crash_report$crash_speed_limit,method="pearson")
##
## Pearson's product-moment correlation
##
## data: Austin_crash_report$motor_vehicle_death_count and Austin_crash_report$crash_speed_limit
## t = 9.4565, df = 161086, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.01867357 0.02843484
## sample estimates:
## cor
## 0.02355476
pairs(~crash_speed_limit+death_cnt+motor_vehicle_death_count+bicycle_death_count+pedestrian_death_count,data=Austin_crash_report)
cor.test(Austin_crash_report$`motor_vehicle_death_count`,Austin_crash_report$crash_speed_limit,method = "pearson")
##
## Pearson's product-moment correlation
##
## data: Austin_crash_report$motor_vehicle_death_count and Austin_crash_report$crash_speed_limit
## t = 9.4565, df = 161086, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.01867357 0.02843484
## sample estimates:
## cor
## 0.02355476
I utilized pesrson because it made the most sense to me as the data is continuous. I ran both kendall and spearman just to try out and was unable to successfully run the data. From what I interpret in this pearson correlation, the data is correlated in increased speed limit compared to vehicle death count. ```