library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.2 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── 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)
district<-read_excel("district.xls")
district_data<-district %>% select(DPETALLC,DA0AT21R ) %>% arrange(-DPETALLC,DA0AT21R )
districtclean<-district |> select(DPETALLC, DA0AT21R ) |> drop_na()
cor(districtclean)
## DPETALLC DA0AT21R
## DPETALLC 1.00000000 0.01608679
## DA0AT21R 0.01608679 1.00000000
pairs(~DPETALLC+DA0AT21R,data=districtclean)
cor.test(district_data$DPETALLC,district_data$DA0AT21R,method = "pearson")
##
## Pearson's product-moment correlation
##
## data: district_data$DPETALLC and district_data$DA0AT21R
## t = 0.55757, df = 1201, p-value = 0.5772
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.04046899 0.07253983
## sample estimates:
## cor
## 0.01608679
The confidence interval does cross 0. p value is near, but just over .05. i used Pearson because the data is linear and and not transformed.