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)
library(pastecs)
##
## Attaching package: 'pastecs'
##
## The following objects are masked from 'package:dplyr':
##
## first, last
##
## The following object is masked from 'package:tidyr':
##
## extract
setwd("C:/Users/David/Desktop/My Class Stuff/Wednesday Class")
data_florida <- read_excel("Data_Florida.xlsx", sheet = "Award Year Summary")
## New names:
## • `Recipients` -> `Recipients...6`
## • `# of Loans Originated` -> `# of Loans Originated...7`
## • `$ of Loans Originated` -> `$ of Loans Originated...8`
## • `# of Disbursements` -> `# of Disbursements...9`
## • `$ of Disbursements` -> `$ of Disbursements...10`
## • `Recipients` -> `Recipients...11`
## • `# of Loans Originated` -> `# of Loans Originated...12`
## • `$ of Loans Originated` -> `$ of Loans Originated...13`
## • `# of Disbursements` -> `# of Disbursements...14`
## • `$ of Disbursements` -> `$ of Disbursements...15`
## • `Recipients` -> `Recipients...16`
## • `# of Loans Originated` -> `# of Loans Originated...17`
## • `$ of Loans Originated` -> `$ of Loans Originated...18`
## • `# of Disbursements` -> `# of Disbursements...19`
## • `$ of Disbursements` -> `$ of Disbursements...20`
## • `Recipients` -> `Recipients...21`
## • `# of Loans Originated` -> `# of Loans Originated...22`
## • `$ of Loans Originated` -> `$ of Loans Originated...23`
## • `# of Disbursements` -> `# of Disbursements...24`
## • `$ of Disbursements` -> `$ of Disbursements...25`
recipients <- as.numeric(data_florida$`Recipients...6`)
loans_count <- as.numeric(data_florida$`# of Loans Originated...7`)
loans_dollars <- as.numeric(data_florida$`$ of Loans Originated...8`)
#2
cor(recipients, loans_count, use = "complete.obs", method = "pearson")
## [1] 0.9998175
cor(recipients, loans_dollars, use = "complete.obs", method = "pearson")
## [1] 0.974388
cor(loans_count, loans_dollars, use = "complete.obs", method = "pearson")
## [1] 0.9736526
#3
pairs(cbind(recipients, loans_count, loans_dollars))

#4
cor.test(recipients, loans_dollars, method = "pearson")
##
## Pearson's product-moment correlation
##
## data: recipients and loans_dollars
## t = 267.74, df = 3818, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.9727332 0.9759436
## sample estimates:
## cor
## 0.974388
#5
#There is a positive correlation between the number of recipients and total loan dollars as they both increase simountaneously. Therefore, the pearson method was used as the variables show a linear line.