library(readxl)
district <- read_excel("district.xls")
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.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.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
obj3 <- district %>% select(DISTNAME,DPETBILP,DPFPABILP)
#1)summary(data$x)
summary(district$DPETBILP)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.00 2.90 7.30 12.58 16.80 100.00
summary(district$DPFPABILP)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 0.0000 0.1000 0.4000 0.7496 1.0000 26.0000 5
summary(obj3)
## DISTNAME DPETBILP DPFPABILP
## Length:1207 Min. : 0.00 Min. : 0.0000
## Class :character 1st Qu.: 2.90 1st Qu.: 0.1000
## Mode :character Median : 7.30 Median : 0.4000
## Mean : 12.58 Mean : 0.7496
## 3rd Qu.: 16.80 3rd Qu.: 1.0000
## Max. :100.00 Max. :26.0000
## NA's :5
#remove the missing observations
obj3_cleaned <- obj3 %>% filter(!is.na(DPFPABILP))
#2)hist(data$x)
hist(district$DPETBILP)
hist(district$DPFPABILP)
#3)plot(data$x,data$y)
plot(district$DPETBILP,district$DPFPABILP)
#4)cor(data$x,data$y)
cor(obj3_cleaned$DPETBILP,obj3_cleaned$DPFPABILP)
## [1] 0.6103153
There is no correlation between the two variables.