library(readxl)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.6
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.1 ✔ tibble 3.3.1
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.2
## ✔ purrr 1.2.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
setwd("C:/Users/qfd738-4251/Desktop/My Class Stuff/Monday Class")
district<-read_excel("district.xls")
your_variable_here<-district %>% select(DISTNAME,DPETSPEP,DPFPASPEP)
your_variable_here<-district %>% select(DPETSPEP,DPFPASPEP)
summary(your_variable_here)
## DPETSPEP DPFPASPEP
## Min. : 0.00 Min. : 0.000
## 1st Qu.: 9.90 1st Qu.: 5.800
## Median :12.10 Median : 8.900
## Mean :12.27 Mean : 9.711
## 3rd Qu.:14.20 3rd Qu.:12.500
## Max. :51.70 Max. :49.000
## NA's :5
5 Values are Missing
your_variable_here %>% drop_na()
## # A tibble: 1,202 × 2
## DPETSPEP DPFPASPEP
## <dbl> <dbl>
## 1 14.6 28.9
## 2 12.1 8.8
## 3 13.1 8.4
## 4 10.5 10.1
## 5 13.5 6.1
## 6 14.5 9.4
## 7 14.7 9.9
## 8 10.4 10.9
## 9 11.6 9.2
## 10 11.9 10.3
## # ℹ 1,192 more rows
1,202 are left over
my_variables_without_NA<-your_variable_here %>% drop_na()
cor(my_variables_without_NA$DPFPASPEP,my_variables_without_NA$DPETSPEP)
## [1] 0.3700234
Slightly correlated, positve correlation