Setting working directory and loading packages

setwd("C:/Users/ianmt/Documents/R")
library(plotly)
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(psych)
## 
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
library(readr)
library(epiDisplay)
## Loading required package: foreign
## Loading required package: survival
## Loading required package: MASS
## 
## Attaching package: 'MASS'
## The following object is masked from 'package:plotly':
## 
##     select
## Loading required package: nnet
## 
## Attaching package: 'epiDisplay'
## The following objects are masked from 'package:psych':
## 
##     alpha, cs, lookup
## The following object is masked from 'package:ggplot2':
## 
##     alpha
library(corrplot)
## corrplot 0.90 loaded
library(reshape2)
library(plyr)
## 
## Attaching package: 'plyr'
## The following objects are masked from 'package:plotly':
## 
##     arrange, mutate, rename, summarise
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:plyr':
## 
##     arrange, count, desc, failwith, id, mutate, rename, summarise,
##     summarize
## The following object is masked from 'package:MASS':
## 
##     select
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(magrittr)
library(ggfortify)
library(devtools)
## Loading required package: usethis
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v tibble  3.1.4     v stringr 1.4.0
## v tidyr   1.1.4     v forcats 0.5.1
## v purrr   0.3.4
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x psych::%+%()        masks ggplot2::%+%()
## x epiDisplay::alpha() masks psych::alpha(), ggplot2::alpha()
## x dplyr::arrange()    masks plyr::arrange(), plotly::arrange()
## x purrr::compact()    masks plyr::compact()
## x dplyr::count()      masks plyr::count()
## x tidyr::extract()    masks magrittr::extract()
## x dplyr::failwith()   masks plyr::failwith()
## x dplyr::filter()     masks plotly::filter(), stats::filter()
## x dplyr::id()         masks plyr::id()
## x dplyr::lag()        masks stats::lag()
## x dplyr::mutate()     masks plyr::mutate(), plotly::mutate()
## x dplyr::rename()     masks plyr::rename(), plotly::rename()
## x dplyr::select()     masks MASS::select(), plotly::select()
## x purrr::set_names()  masks magrittr::set_names()
## x dplyr::summarise()  masks plyr::summarise(), plotly::summarise()
## x dplyr::summarize()  masks plyr::summarize()
library(ggthemes)
library(ggdist)
library(ggplot2)

Southeast Michigan Ag Census data by Zip Code

#Zip and County join Ag data
SEagCZip<- read.csv("~/R/SE_CountyZip_joinOto.csv")
#View(SEagCZip)
#str(SEagCZip)

Descriptive Statistics of Select Variables

Descriptions of Ops w/ Federal Support

summary(SEagCZip$OpsCCCLoans)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.0000  0.0000  0.0000  0.2986  0.0000  5.0000
mean(SEagCZip$OpsCCCLoans)
## [1] 0.2985612
median(SEagCZip$OpsCCCLoans)
## [1] 0
sd(SEagCZip$OpsCCCLoans)
## [1] 0.8199221
hist(SEagCZip$OpsCCCLoans, main = 'Histogram of Operations with Federal Commodity Loans', xlab = 'Operations with Federal Commodity Loans', col = 'Gold')

summary(SEagCZip$OpsCCCLoans/SEagCZip$OpsTotal)
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## 0.000000 0.000000 0.000000 0.004704 0.000000 0.125000
mean(SEagCZip$OpsCCCLoans/SEagCZip$OpsTotal)
## [1] 0.004703907
median(SEagCZip$OpsCCCLoans/SEagCZip$OpsTotal)
## [1] 0
sd(SEagCZip$OpsCCCLoans/SEagCZip$OpsTotal)
## [1] 0.01523405
hist(SEagCZip$OpsCCCLoans, main = 'Histogram of % Operations with Federal Commodity Loans', xlab = 'Operations with Federal Commodity Loans (%)', col = 'Gold')

summary(SEagCZip$OpsFedCons)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   0.000   0.000   1.000   4.561   3.750  88.000
mean(SEagCZip$OpsFedCons)
## [1] 4.561151
median(SEagCZip$OpsFedCons)
## [1] 1
sd(SEagCZip$OpsFedCons)
## [1] 10.6083
hist(SEagCZip$OpsFedCons, main = 'Histogram of Operations with Federal Conservation Funding', xlab = 'Operations with Federal Conservation Funding', col = 'Gold')

summary(SEagCZip$OpsFedCons/SEagCZip$OpsTotal)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 0.00000 0.00000 0.03486 0.12587 0.17803 1.00000
mean(SEagCZip$OpsFedCons/SEagCZip$OpsTotal)
## [1] 0.1258696
median(SEagCZip$OpsFedCons/SEagCZip$OpsTotal)
## [1] 0.03485988
sd(SEagCZip$OpsFedCons/SEagCZip$OpsTotal)
## [1] 0.1949865
hist(SEagCZip$OpsFedCons, main = 'Histogram of % Operations with Federal Conservation Funding', xlab = 'Operations with Federal Conservation Funding (%)', col = 'Gold')

summary(SEagCZip$OpsFedProgram)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    1.00    3.00   13.41   19.00  122.00
FedProg2 <- na.omit(SEagCZip$OpsFedProgram)
mean(FedProg2)
## [1] 13.40647
median(FedProg2)
## [1] 3
sd(FedProg2)
## [1] 20.86791
hist(FedProg2, main = 'Histogram of Operations with Federal Programs', xlab = 'Operations with Federal Programs', col = 'Gold')

summary(SEagCZip$OpsFedProgram/SEagCZip$OpsTotal)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.0000  0.0625  0.2300  0.2838  0.4365  1.0000
FedProg2 <- na.omit(SEagCZip$OpsFedProgram/SEagCZip$OpsTotal)
mean(FedProg2)
## [1] 0.2837823
median(FedProg2)
## [1] 0.2299679
sd(FedProg2)
## [1] 0.2620423
hist(FedProg2, main = 'Histogram of Operations with Federal Programs (%)', xlab = 'Operations with Federal Programs (%)', col = 'Gold')

Descriptions of Ag Ownership and Tenancy

summary(SEagCZip$FullOwn)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    4.00   15.50   28.99   44.00  169.00
mean(SEagCZip$FullOwn)
## [1] 28.98561
median(SEagCZip$FullOwn)
## [1] 15.5
sd(SEagCZip$FullOwn)
## [1] 33.73757
hist(SEagCZip$FullOwn, main = 'Histogram of Operations with Full Ownership', xlab = 'Operations with Full Ownership', col = 'Green')

summary(SEagCZip$FullOwn/SEagCZip$OpsTotal)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.0000  0.6313  0.7692  0.7670  1.0000  1.0000
mean(SEagCZip$FullOwn/SEagCZip$OpsTotal)
## [1] 0.7669824
median(SEagCZip$FullOwn/SEagCZip$OpsTotal)
## [1] 0.7692308
sd(SEagCZip$FullOwn/SEagCZip$OpsTotal)
## [1] 0.2283978
hist(SEagCZip$FullOwn, main = 'Histogram of Operations with Full Ownership (%)', xlab = 'Operations with Full Ownership (%)', col = 'Green')

summary(SEagCZip$PartOwn)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    0.00    3.00   11.56   19.00   84.00
mean(SEagCZip$PartOwn)
## [1] 11.56115
median(SEagCZip$PartOwn)
## [1] 3
sd(SEagCZip$PartOwn)
## [1] 15.96956
hist(SEagCZip$PartOwn, main = 'Histogram of Operations with Part Ownership', xlab = 'Operations with Part Ownership', col = 'Green')

summary(SEagCZip$PartOwn/SEagCZip$OpsTotal)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.0000  0.0000  0.1250  0.1708  0.3075  1.0000
mean(SEagCZip$PartOwn/SEagCZip$OpsTotal)
## [1] 0.1707933
median(SEagCZip$PartOwn/SEagCZip$OpsTotal)
## [1] 0.125
sd(SEagCZip$PartOwn/SEagCZip$OpsTotal)
## [1] 0.1840436
hist(SEagCZip$PartOwn/SEagCZip$OpsTotal, main = 'Histogram of Operations with Part Ownership (%)', xlab = 'Operations with Part Ownership (%)', col = 'Green')

summary(SEagCZip$Tenant)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   0.000   0.000   0.000   2.216   3.000  23.000
mean(SEagCZip$Tenant)
## [1] 2.215827
median(SEagCZip$Tenant)
## [1] 0
sd(SEagCZip$Tenant)
## [1] 3.654309
hist(SEagCZip$Tenant, main = 'Histogram of Operations with Tenancy', xlab = 'Operations with Tenancy', col = 'Green')

summary(SEagCZip$Tenant/SEagCZip$OpsTotal)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 0.00000 0.00000 0.00000 0.06222 0.06231 1.00000
mean(SEagCZip$Tenant/SEagCZip$OpsTotal)
## [1] 0.06222432
median(SEagCZip$Tenant/SEagCZip$OpsTotal)
## [1] 0
sd(SEagCZip$Tenant/SEagCZip$OpsTotal)
## [1] 0.1553946
hist(SEagCZip$Tenant/SEagCZip$OpsTotal, main = 'Histogram of Operations with Tenancy (%)', xlab = 'Operations with Tenancy (%)', col = 'Green')

Correlation Testing for Zip Code Ag data

Ops w/ Federal Commodity Loans

cor.test((SEagCZip$FullOwn/SEagCZip$OpsTotal), (SEagCZip$OpsCCCLoan/SEagCZip$OpsTotal), use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  (SEagCZip$FullOwn/SEagCZip$OpsTotal) and (SEagCZip$OpsCCCLoan/SEagCZip$OpsTotal)
## t = -4.6964, df = 276, p-value = 4.178e-06
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.3775909 -0.1594930
## sample estimates:
##        cor 
## -0.2720318
plot((SEagCZip$FullOwn/SEagCZip$OpsTotal), (SEagCZip$OpsCCCLoan/SEagCZip$OpsTotal), main = 'Operations with Federal Commodity Loans ~ Full Ownership', xlab = 'Full Ownership (%)', ylab = 'Ops w/ Fed Commodity Loan (%)', col = 'Blue')

cor.test((SEagCZip$Tenant/SEagCZip$OpsTotal), (SEagCZip$OpsCCCLoan/SEagCZip$OpsTotal), use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  (SEagCZip$Tenant/SEagCZip$OpsTotal) and (SEagCZip$OpsCCCLoan/SEagCZip$OpsTotal)
## t = -0.54157, df = 276, p-value = 0.5886
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.14965052  0.08538918
## sample estimates:
##         cor 
## -0.03258112
plot((SEagCZip$Tenant/SEagCZip$OpsTotal), (SEagCZip$OpsCCCLoan/SEagCZip$OpsTotal), main = 'Operations with Federal Commodity Loans ~ Tenant Operations (%)', xlab = 'Tenant Operations (%)', ylab = 'Ops w/ Fed Commodity Loan (%)', col = 'Blue')

cor.test(SEagCZip$ALAND, (SEagCZip$OpsCCCLoan/SEagCZip$OpsTotal), use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  SEagCZip$ALAND and (SEagCZip$OpsCCCLoan/SEagCZip$OpsTotal)
## t = 2.8021, df = 276, p-value = 0.005437
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.04964525 0.27851056
## sample estimates:
##       cor 
## 0.1663169
plot(SEagCZip$ALAND, (SEagCZip$OpsCCCLoan/SEagCZip$OpsTotal), main = 'Operations with Federal Commodity Loans ~ Land Area', xlab = 'Land Area (m)', ylab = 'Ops w/ Fed Commodity Loan (%)', col = 'Blue')

Ops w/ Federal Program

cor.test((SEagCZip$FullOwn/SEagCZip$OpsTotal), (SEagCZip$OpsFedProgram/SEagCZip$OpsTotal), use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  (SEagCZip$FullOwn/SEagCZip$OpsTotal) and (SEagCZip$OpsFedProgram/SEagCZip$OpsTotal)
## t = -1.3783, df = 276, p-value = 0.1692
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.19839084  0.03530897
## sample estimates:
##         cor 
## -0.08267747
plot((SEagCZip$FullOwn/SEagCZip$OpsTotal), (SEagCZip$OpsFedProgram/SEagCZip$OpsTotal), main = 'Operations with Federal Programs ~ Ful Ownership', xlab = 'Full Ownership (%)', ylab = 'Ops w/ Fed Programs (%)', col = 'Gold')

cor.test((SEagCZip$Tenant/SEagCZip$OpsTotal), (SEagCZip$OpsFedProgram/SEagCZip$OpsTotal), use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  (SEagCZip$Tenant/SEagCZip$OpsTotal) and (SEagCZip$OpsFedProgram/SEagCZip$OpsTotal)
## t = -1.5313, df = 276, p-value = 0.1268
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.20719089  0.02614015
## sample estimates:
##         cor 
## -0.09178511
plot((SEagCZip$Tenant/SEagCZip$OpsTotal), (SEagCZip$OpsFedProgram/SEagCZip$OpsTotal), main = 'Operations with Federal Programs ~ Tenant Operations', xlab = 'Tenant Operations (%)', ylab = 'Ops w/ Fed Programs (%)', col = 'Gold')

cor.test(SEagCZip$ALAND, (SEagCZip$OpsFedProgram/SEagCZip$OpsTotal), use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  SEagCZip$ALAND and (SEagCZip$OpsFedProgram/SEagCZip$OpsTotal)
## t = 1.4572, df = 276, p-value = 0.1462
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.03058014  0.20293419
## sample estimates:
##        cor 
## 0.08737721
plot((SEagCZip$ALAND/SEagCZip$OpsTotal), (SEagCZip$OpsFedProgram/SEagCZip$OpsTotal), main = 'Operations with Federal Programs ~ Land Area', xlab = 'Land Area (m)', ylab = 'Ops w/ Fed Programs (%)', col = 'Gold')

Ops w/ Federal Conservation Funding

cor.test((SEagCZip$FullOwn/SEagCZip$OpsTotal), (SEagCZip$OpsFedCons/SEagCZip$OpsTotal), use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  (SEagCZip$FullOwn/SEagCZip$OpsTotal) and (SEagCZip$OpsFedCons/SEagCZip$OpsTotal)
## t = 2.0727, df = 276, p-value = 0.03913
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.006248236 0.237977283
## sample estimates:
##       cor 
## 0.1238002
plot((SEagCZip$FullOwn/SEagCZip$OpsTotal), (SEagCZip$OpsFedCons/SEagCZip$OpsTotal), main = 'Federal Conservation Funding Ops ~ Full Ownership', xlab = 'Full Ownership (%)', ylab = 'Ops w/ Fed Conservation Funding (%)', col = 'Green')

cor.test((SEagCZip$Tenant/SEagCZip$OpsTotal), (SEagCZip$OpsFedCons/SEagCZip$OpsTotal), use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  (SEagCZip$Tenant/SEagCZip$OpsTotal) and (SEagCZip$OpsFedCons/SEagCZip$OpsTotal)
## t = -2.1178, df = 276, p-value = 0.03508
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.24051966 -0.00894482
## sample estimates:
##        cor 
## -0.1264548
plot((SEagCZip$Tenant/SEagCZip$OpsTotal), (SEagCZip$OpsFedCons/SEagCZip$OpsTotal), main = 'Federal Conservation Funding Ops ~ Tenant Operations', xlab = 'Tenant Operations (%)', ylab = 'Ops w/ Fed Conservation Funding (%)', col = 'Green')

cor.test(SEagCZip$ALAND10, (SEagCZip$OpsFedCons/SEagCZip$OpsTotal), use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  SEagCZip$ALAND10 and (SEagCZip$OpsFedCons/SEagCZip$OpsTotal)
## t = -1.3037, df = 276, p-value = 0.1934
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.19409000  0.03977576
## sample estimates:
##         cor 
## -0.07823332
plot(SEagCZip$ALAND10, (SEagCZip$OpsFedCons/SEagCZip$OpsTotal), main = 'Federal Conservation Funding Ops ~ Land Area', xlab = 'Land Area (m)', ylab = 'Ops w/ Fed Conservation Funding (%)', col = 'Green')

Aggregated Demographic and Ag Data by Zip Code

AggCenAg <- read.csv("~/R/SE_AgZip_CenAgg.csv")
#str(AggCenAg)
#View(AggCenAg)

Descriptive Statistics of Aggregated Census and Ag Data

General Demographic Descriptions

summary(AggCenAg$TotalHH)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##       7    1138    1557    1574    1984    3553
mean(AggCenAg$TotalHH)
## [1] 1574.361
median(AggCenAg$TotalHH)
## [1] 1557
sd(AggCenAg$TotalHH)
## [1] 607.3061
hist(AggCenAg$TotalHH, main = 'Histogram of Total Households', xlab = 'Total Households', col = 'Blue')

summary(AggCenAg$TotalPop)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##      20    2909    3925    4044    5018   11067
mean(AggCenAg$TotalPop)
## [1] 4044.184
median(AggCenAg$TotalPop)
## [1] 3925
sd(AggCenAg$TotalPop)
## [1] 1625.427
hist(AggCenAg$TotalPop, main = 'Histogram of Total Population', xlab = 'Total Population', col = 'Blue')

summary(AggCenAg$Popage25plus)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##      11    2038    2726    2802    3467    7021
mean(AggCenAg$Popage25plus)
## [1] 2802.184
median(AggCenAg$Popage25plus)
## [1] 2726
sd(AggCenAg$Popage25plus)
## [1] 1099.009
hist(AggCenAg$Popage25plus, main = 'Histogram of Total Population age 25 plus', xlab = 'Population Age 25 plus', col = 'Blue')

summary(AggCenAg$pBipoc)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00    3.00    6.00   15.66   19.00   99.00
mean(AggCenAg$pBipoc)
## [1] 15.66426
median(AggCenAg$pBipoc)
## [1] 6
sd(AggCenAg$pBipoc)
## [1] 20.98289
hist(AggCenAg$pBipoc, main = 'Histogram of BIPOC Residents (%)', xlab = 'BIPOC Residents (%)', col = 'Blue')

summary(AggCenAg$pWhite)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1.00   81.00   94.00   84.34   97.00  100.00
mean(AggCenAg$pWhite)
## [1] 84.33574
median(AggCenAg$pWhite)
## [1] 94
sd(AggCenAg$pWhite)
## [1] 20.98289
hist(AggCenAg$pWhite, main = 'Histogram of White Residents (%)', xlab = 'White Residents (%)', col = 'Blue')

Income and Education

summary(AggCenAg$MedianHHIncome)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##   17012   54719   66947   73237   84270  192772       2
mean(AggCenAg$MedianHHIncome)
## [1] NA
median(AggCenAg$MedianHHIncome)
## [1] NA
sd(AggCenAg$MedianHHIncome)
## [1] NA
hist(AggCenAg$MedianHHIncome, main = 'Histogram of Median Household Income', xlab = 'Median Household Income ($)', col = 'Gold')

summary(AggCenAg$HHSnap12mon)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0    45.0   106.0   146.9   193.0   836.0
mean(AggCenAg$HHSnap12mon)
## [1] 146.8917
median(AggCenAg$HHSnap12mon)
## [1] 106
sd(AggCenAg$HHSnap12mon)
## [1] 143.7071
hist(AggCenAg$HHSnap12mon, main = 'Histogram of Household SNAP users', xlab = 'Household SNAP users', col = 'Gold')

summary(AggCenAg$HHSnap12mon/AggCenAg$TotalHH)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 0.00000 0.03431 0.07343 0.09857 0.11938 0.58747
mean(AggCenAg$HHSnap12mon/AggCenAg$TotalHH)
## [1] 0.09857445
median(AggCenAg$HHSnap12mon/AggCenAg$TotalHH)
## [1] 0.07343192
sd(AggCenAg$HHSnap12mon/AggCenAg$TotalHH)
## [1] 0.1000013
hist(AggCenAg$HHSnap12mon/AggCenAg$TotalHH, main = 'Histogram of Household SNAP users (%)', xlab = 'Household SNAP users (%)', col = 'Gold')

summary(AggCenAg$Pop25NoHS)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0   108.0   176.0   212.9   269.0  1111.0
mean(AggCenAg$Pop25NoHS)
## [1] 212.8736
median(AggCenAg$Pop25NoHS)
## [1] 176
sd(AggCenAg$Pop25NoHS)
## [1] 160.3449
hist(AggCenAg$Pop25NoHS, main = 'Histogram of Population age 25 plus w/ No High School', xlab = 'Population Age 25 plus w/ No High School', col = 'Gold')

summary(AggCenAg$Pop25NoHS/AggCenAg$Popage25plus)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 0.00000 0.04162 0.06826 0.08042 0.10039 0.37209
mean(AggCenAg$Pop25NoHS/AggCenAg$Popage25plus)
## [1] 0.0804154
median(AggCenAg$Pop25NoHS/AggCenAg$Popage25plus)
## [1] 0.06825658
sd(AggCenAg$Pop25NoHS/AggCenAg$Popage25plus)
## [1] 0.05784699
hist(AggCenAg$Pop25NoHS/AggCenAg$Popage25plus, main = 'Histogram of Population age 25 plus w/ No High School (%)', xlab = 'Population Age 25 plus w/ No High School (%)', col = 'Gold')

Correlation Testing of Select Demographic and Ag Variables

Matrix Plot

AggCenAg1 <- AggCenAg[complete.cases(AggCenAg),]
AggCenAg2 <- AggCenAg1[-c(1,15,15,46,47)]
#View(AggCenAg2)
#str(AggCenAg2)
CorAggCenAg2 <- cor(AggCenAg2)
corrplot(CorAggCenAg2, is.corr = FALSE, method = "square")

Demographic Correlations

cor.test(AggCenAg$pBipoc, AggCenAg$MedianHHIncome, use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  AggCenAg$pBipoc and AggCenAg$MedianHHIncome
## t = -4.1236, df = 273, p-value = 4.955e-05
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.3503901 -0.1275099
## sample estimates:
##        cor 
## -0.2421418
plot(AggCenAg$pBipoc, AggCenAg$MedianHHIncome, main = 'Median Household Income ~ BIPOC Residents', xlab = 'BIPOC Residents (%)', ylab = 'Median Household Income ($)', col = 'Blue')

cor.test(AggCenAg$pBipoc, (AggCenAg$HHSnap12mon/AggCenAg$TotalHH), use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  AggCenAg$pBipoc and (AggCenAg$HHSnap12mon/AggCenAg$TotalHH)
## t = 10.539, df = 275, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.446766 0.615336
## sample estimates:
##       cor 
## 0.5363791
plot(AggCenAg$pBipoc, (AggCenAg$HHSnap12mon/AggCenAg$TotalHH), main = 'Household SNAP Users ~ BIPOC Residents', xlab = 'BIPOC Residents (%)', ylab = 'Household SNAP Users (%)', col = 'Blue')

cor.test(AggCenAg$pWhite, AggCenAg$MedianHHIncome, use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  AggCenAg$pWhite and AggCenAg$MedianHHIncome
## t = 4.1236, df = 273, p-value = 4.955e-05
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1275099 0.3503901
## sample estimates:
##       cor 
## 0.2421418
cor.test(AggCenAg$pWhite, (AggCenAg$HHSnap12mon/AggCenAg$TotalHH), use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  AggCenAg$pWhite and (AggCenAg$HHSnap12mon/AggCenAg$TotalHH)
## t = -10.539, df = 275, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.615336 -0.446766
## sample estimates:
##        cor 
## -0.5363791
cor.test((AggCenAg$Pop25NoHS/AggCenAg$Popage25plus), AggCenAg$MedianHHIn, use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  (AggCenAg$Pop25NoHS/AggCenAg$Popage25plus) and AggCenAg$MedianHHIn
## t = -12.443, df = 273, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.6720349 -0.5203096
## sample estimates:
##        cor 
## -0.6015704
plot((AggCenAg$Pop25NoHS/AggCenAg$Popage25plus), AggCenAg$MedianHHIncome, main = 'Median Household Income ~ Residents without High School Ed', xlab = 'Residents Without HS Ed (%)', ylab = 'Median Household Income ($)', col = 'Blue')

Demographic and Ag Correlations

cor.test(AggCenAg$pBipoc, AggCenAg$OpsTotal, use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  AggCenAg$pBipoc and AggCenAg$OpsTotal
## t = -6.838, df = 275, p-value = 5.187e-11
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.477606 -0.275741
## sample estimates:
##        cor 
## -0.3812082
plot(AggCenAg$pBipoc, AggCenAg$OpsTotal, main = 'Total Ag Operations ~ BIPOC Residents', xlab = 'BIPOC Residents (%)', ylab = 'Total Ag Operations', col = 'Gold')

cor.test(AggCenAg$pWhite, AggCenAg$OpsTotal, use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  AggCenAg$pWhite and AggCenAg$OpsTotal
## t = 6.838, df = 275, p-value = 5.187e-11
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.275741 0.477606
## sample estimates:
##       cor 
## 0.3812082
cor.test(AggCenAg$pBipoc, AggCenAg$ProdTotal, use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  AggCenAg$pBipoc and AggCenAg$ProdTotal
## t = -6.7764, df = 275, p-value = 7.479e-11
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.4749520 -0.2725663
## sample estimates:
##        cor 
## -0.3782705
plot(AggCenAg$pBipoc, AggCenAg$ProdTotal, main = 'Total Producers ~ BIPOC Residents', xlab = 'BIPOC Residents (%)', ylab = 'Total Producers', col = 'Gold')

cor.test(AggCenAg$pWhite, AggCenAg$ProdTotal, use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  AggCenAg$pWhite and AggCenAg$ProdTotal
## t = 6.7764, df = 275, p-value = 7.479e-11
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.2725663 0.4749520
## sample estimates:
##       cor 
## 0.3782705
cor.test(AggCenAg$pBipoc, AggCenAg$pTenant, use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  AggCenAg$pBipoc and AggCenAg$pTenant
## t = 4.1232, df = 275, p-value = 4.953e-05
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1270480 0.3492153
## sample estimates:
##       cor 
## 0.2412905
plot(AggCenAg$pBipoc, AggCenAg$pTenant, main = 'Tenant Operations ~ BIPOC Residents', xlab = 'BIPOC Residents (%)', ylab = 'Tenant Operations (%)', col = 'Gold')

cor.test(AggCenAg$pWhite, AggCenAg$pTenant, use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  AggCenAg$pWhite and AggCenAg$pTenant
## t = -4.1232, df = 275, p-value = 4.953e-05
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.3492153 -0.1270480
## sample estimates:
##        cor 
## -0.2412905
cor.test(AggCenAg$pBipoc, AggCenAg$pFullOwn, use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  AggCenAg$pBipoc and AggCenAg$pFullOwn
## t = 0.91467, df = 275, p-value = 0.3612
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.06319246  0.17181350
## sample estimates:
##        cor 
## 0.05507319
plot(AggCenAg$pBipoc, AggCenAg$pFullOwn, main = 'Fully Owned Operations ~ BIPOC Residents', xlab = 'BIPOC Residents (%)', ylab = 'Fully Owned Operations (%)', col = 'Gold')

cor.test(AggCenAg$pWhite, AggCenAg$pFullOwn, use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  AggCenAg$pWhite and AggCenAg$pFullOwn
## t = -0.91467, df = 275, p-value = 0.3612
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.17181350  0.06319246
## sample estimates:
##         cor 
## -0.05507319
cor.test(AggCenAg$pBipoc, (AggCenAg$OpsCCCLoan/AggCenAg$OpsTotal), use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  AggCenAg$pBipoc and (AggCenAg$OpsCCCLoan/AggCenAg$OpsTotal)
## t = -2.2651, df = 275, p-value = 0.02428
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.24921517 -0.01776246
## sample estimates:
##        cor 
## -0.1353346
plot(AggCenAg$pBipoc, (AggCenAg$OpsCCCLoan/AggCenAg$OpsTotal), main = 'Ops w/ Federal Commodity Loans ~ BIPOC Residents', xlab = 'BIPOC Residents (%)', ylab = 'Ops w/ Fed Commodity Loans (%)', col = 'Gold')

cor.test(AggCenAg$pWhite, (AggCenAg$OpsCCCLoan/AggCenAg$OpsTotal), use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  AggCenAg$pWhite and (AggCenAg$OpsCCCLoan/AggCenAg$OpsTotal)
## t = 2.2651, df = 275, p-value = 0.02428
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.01776246 0.24921517
## sample estimates:
##       cor 
## 0.1353346
plot(AggCenAg$pWhite, (AggCenAg$OpsCCCLoan/AggCenAg$OpsTotal), main = 'Ops w/ Federal Commodity Loans ~ White Residents', xlab = 'White Residents (%)', ylab = 'Ops w/ Fed Commodity Loans (%)', col = 'Gold')

cor.test(AggCenAg$pBipoc, (AggCenAg$OpsFedProgram/AggCenAg$OpsTotal), use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  AggCenAg$pBipoc and (AggCenAg$OpsFedProgram/AggCenAg$OpsTotal)
## t = -1.2675, df = 275, p-value = 0.2061
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.19233648  0.04202447
## sample estimates:
##         cor 
## -0.07620847
plot(AggCenAg$pBipoc, (AggCenAg$OpsFedProgram/AggCenAg$OpsTotal), main = 'Ops w/ Federal Program ~ BIPOC Residents', xlab = 'BIPOC Residents (%)', ylab = 'Ops w/ Fed Program (%)', col = 'Gold')

cor.test(AggCenAg$pWhite, (AggCenAg$OpsFedProgram/AggCenAg$OpsTotal), use = "complete obs", method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  AggCenAg$pWhite and (AggCenAg$OpsFedProgram/AggCenAg$OpsTotal)
## t = 1.2675, df = 275, p-value = 0.2061
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.04202447  0.19233648
## sample estimates:
##        cor 
## 0.07620847
plot(AggCenAg$pWhite, (AggCenAg$OpsFedProgram/AggCenAg$OpsTotal), main = 'Ops w/ Federal Program ~ White Residents', xlab = 'White Residents (%)', ylab = 'Ops w/ Fed Program (%)', col = 'Gold')

Aggregate Demographic Variable Correlations by County

Median Income ~ BIPOC Residents

ggplot(AggCenAg,
       aes(x = pBipoc,
           y = MedianHHIncome,
           color = County))+
  geom_point()+
  scale_color_manual(values = c("red4", "orange1", "lightpink","yellow", "blue", "hotpink", "cyan", "gold", "gray10","darkorchid", "mediumseagreen"))+
  labs(title = "Median Household Income ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Median Household Income")
## Warning: Removed 2 rows containing missing values (geom_point).

ggplot(AggCenAg,
       aes(x = pBipoc,
           y = MedianHHIncome,
           color = County))+
  geom_jitter()+
  scale_color_manual(values = c("red4", "orange1", "lightpink","yellow", "blue", "hotpink", "cyan", "gold", "gray10","darkorchid", "mediumseagreen"))+
  facet_wrap(~County)+
  labs(title = "Median Household Income ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Median Household Income")
## Warning: Removed 2 rows containing missing values (geom_point).

ggplot(AggCenAg,
       aes(x = pBipoc,
           y = MedianHHIncome,
           color = TotalPop))+
  geom_point()+
  geom_smooth()+
  labs(title = "Median Household Income ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Median Household Income")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 2 rows containing non-finite values (stat_smooth).

## Warning: Removed 2 rows containing missing values (geom_point).

SNAP ~ BIPOC Residents

ggplot(AggCenAg,
       aes(x = pBipoc,
           y = HHSnap12mon/TotalHH,
           color = County))+
  geom_point()+
  scale_color_manual(values = c("red4", "orange1", "lightpink","yellow", "blue", "hotpink", "cyan", "gold", "gray10","darkorchid", "mediumseagreen"))+
  labs(title = "Household SNAP Users ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Houshold SNAP Users (%)")

ggplot(AggCenAg,
       aes(x = pBipoc,
           y = HHSnap12mon/TotalHH,
           color = County))+
  geom_jitter()+
  scale_color_manual(values = c("red4", "orange1", "lightpink","yellow", "blue", "hotpink", "cyan", "gold", "gray10","darkorchid", "mediumseagreen"))+
  facet_wrap(~County)+
  labs(title = "Household SNAP Users ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Household SNAP Users ($)")

ggplot(AggCenAg,
       aes(x = pBipoc,
           y = HHSnap12mon/TotalHH,
           color = TotalPop))+
  geom_point()+
  geom_smooth()+
 labs(title = "Household SNAP Users ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Household SNAP Users (%)")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

Ag and Demographic Variable Correlations by County

Total Ag Operations ~ BIPOC Residents

ggplot(AggCenAg,
       aes(x = pBipoc,
           y = OpsTotal,
           color = County))+
  geom_point()+
  scale_color_manual(values = c("red4", "orange1", "lightpink","yellow", "blue", "hotpink", "cyan", "gold", "gray10","darkorchid", "mediumseagreen"))+
  labs(title = "Total Ag Operations ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Total Ag Operations")

ggplot(AggCenAg,
      aes(x = pBipoc,
           y = OpsTotal,
           color = County))+
  geom_jitter()+
  scale_color_manual(values = c("red4", "orange1", "lightpink","yellow", "blue", "hotpink", "cyan", "gold", "gray10","darkorchid", "mediumseagreen"))+
  facet_wrap(~County)+
  labs(title = "Total Ag Operations ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Total Ag Operations ")

ggplot(AggCenAg,
       aes(x = pBipoc,
           y = OpsTotal,
           color = ALAND))+
  geom_point()+
  geom_smooth()+
 labs(title = "Total Ag Operations ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Total Ag Operations")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

Tenant Operations ~ BIPOC Residents

ggplot(AggCenAg,
       aes(x = pBipoc,
           y = pTenant,
           color = County))+
  geom_point()+
  scale_color_manual(values = c("red4", "orange1", "lightpink","yellow", "blue", "hotpink", "cyan", "gold", "gray10","darkorchid", "mediumseagreen"))+
  labs(title = "Tenant Operations ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Tenant Operations (%)")

ggplot(AggCenAg,
       aes(x = pBipoc,
           y = pTenant,
           color = County))+
  geom_jitter()+
  scale_color_manual(values = c("red4", "orange1", "lightpink","yellow", "blue", "hotpink", "cyan", "gold", "gray10","darkorchid", "mediumseagreen"))+
  facet_wrap(~County)+
  labs(title = "Tenant Operations ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Tenant Operations (%)")

ggplot(AggCenAg,
      aes(x = pBipoc,
          y = pTenant,
          color = MedianHHIncome))+
  geom_point()+
  geom_smooth()+
  labs(title = "Tenant Operations ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Tenant operations (%)")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

Full Ownership ~ BIPOC Residents

ggplot(AggCenAg,
       aes(x = pBipoc,
           y = pFullOwn,
           color = County))+
  geom_point()+
  scale_color_manual(values = c("red4", "orange1", "lightpink","yellow", "blue", "hotpink", "cyan", "gold", "gray10","darkorchid", "mediumseagreen"))+
  labs(title = "Fully Owned Operations ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Fully Owned Operations (%)")

ggplot(AggCenAg,
       aes(x = pBipoc,
           y = pFullOwn,
           color = County))+
  geom_jitter()+
  scale_color_manual(values = c("red4", "orange1", "lightpink","yellow", "blue", "hotpink", "cyan", "gold", "gray10","darkorchid", "mediumseagreen"))+
  facet_wrap(~County)+
labs(title = "Fully Owned Operations ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Fully Owned Operations (%)")

ggplot(AggCenAg,
       aes(x = pBipoc,
           y = pFullOwn,
          color = OpsTotal))+
  geom_point()+
  geom_smooth()+
  labs(title = "Fully Owned Operations ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Fully Owned Operations (%)")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

Fed Commodity Loans ~ BIPOC Residents

ggplot(AggCenAg,
       aes(x = pBipoc,
           y = OpsCCCLoans/OpsTotal,
           color = County))+
  geom_point()+
  scale_color_manual(values = c("red4", "orange1", "lightpink","yellow", "blue", "hotpink", "cyan", "gold", "gray10","darkorchid", "mediumseagreen"))+
  labs(title = "Ops w/ Federal Commodity Loans ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Ops w/ Fed Commodity Loans (%)")

ggplot(AggCenAg,
       aes(x = pBipoc,
           y = OpsCCCLoans/OpsTotal,
           color = County))+
  geom_jitter()+
  scale_color_manual(values = c("red4", "orange1", "lightpink","yellow", "blue", "hotpink", "cyan", "gold", "gray10","darkorchid", "mediumseagreen"))+
  facet_wrap(~County)+
  labs(title = "Ops w/ Federal Commodity Loans ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Ops w/ Fed Commodity Loans (%)")

ggplot(AggCenAg,
       aes(x = pBipoc,
           y = OpsCCCLoans/OpsTotal,
           color = ALAND))+
  geom_point()+
  geom_smooth()+
 labs(title = "Ops w/ Federal Commodity Loans ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Ops w/ Fed Commodity Loans (%)")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

Fed Commodity Loans ~ Tenant Operations

ggplot(AggCenAg,
       aes(x = pTenant,
           y = OpsCCCLoans/OpsTotal,
           color = County))+
  geom_point()+
  scale_color_manual(values = c("red4", "orange1", "lightpink","yellow", "blue", "hotpink", "cyan", "gold", "gray10","darkorchid", "mediumseagreen"))+
  labs(title = "Ops w/ Federal Commodity Loans ~ Tenant Operations",
       x = "Tenant Operations (%)",
       y = "Ops w/ Fed Commodity Loans (%)")

ggplot(AggCenAg,
       aes(x = pTenant,
           y = OpsCCCLoans/OpsTotal,
           color = County))+
  geom_jitter()+
  scale_color_manual(values = c("red4", "orange1", "lightpink","yellow", "blue", "hotpink", "cyan", "gold", "gray10","darkorchid", "mediumseagreen"))+
  facet_wrap(~County)+
  labs(title = "Ops w/ Federal Commodity Loans ~ Tenant Operations",
       x = "Tenant Operations (%)",
       y = "Ops w/ Fed Commodity Loans (%)")

ggplot(AggCenAg,
       aes(x = pTenant,
           y = OpsCCCLoans/OpsTotal,
           color = OpsTotal))+
  geom_point()+
  geom_smooth()+
 labs(title = "Ops w/ Federal Commodity Loans ~ Tenant Operations",
       x = "Tenant Operations (%)",
       y = "Ops w/ Fed Commodity Loans (%)")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

Ops w/ Fed Program ~ BIPOC Residents

ggplot(AggCenAg,
       aes(x = pBipoc,
           y = OpsFedProgram/OpsTotal,
           color = County))+
  geom_point()+
  scale_color_manual(values = c("red4", "orange1", "lightpink","yellow", "blue", "hotpink", "cyan", "gold", "gray10","darkorchid", "mediumseagreen"))+
  labs(title = "Ops w/ Federal Program ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Ops w/ Fed Program (%)")

ggplot(AggCenAg,
       aes(x = pBipoc,
           y = OpsFedProgram/OpsTotal,
           color = County))+
  geom_jitter()+
  scale_color_manual(values = c("red4", "orange1", "lightpink","yellow", "blue", "hotpink", "cyan", "gold", "gray10","darkorchid", "mediumseagreen"))+
  facet_wrap(~County)+
  labs(title = "Ops w/ Federal Program ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Ops w/ Fed Program (%)")

ggplot(AggCenAg,
       aes(x = pBipoc,
           y = OpsFedProgram/OpsTotal,
           color = ALAND))+
  geom_point()+
  geom_smooth()+
 labs(title = "Ops w/ Federal Program ~ BIPOC Residents",
       x = "BIPOC Residents (%)",
       y = "Ops w/ Fed Program (%)")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

Operations w/ Federal Program ~ Tenant Operations

ggplot(AggCenAg,
       aes(x = pTenant,
           y = OpsFedProgram/OpsTotal,
           color = County))+
  geom_point()+
  scale_color_manual(values = c("red4", "orange1", "lightpink","yellow", "blue", "hotpink", "cyan", "gold", "gray10","darkorchid", "mediumseagreen"))+
  labs(title = "Ops w/ Federal Program ~ Tenant Operations",
       x = "Tenant Operations (%)",
       y = "Ops w/ Fed Program (%)")

ggplot(AggCenAg,
       aes(x = pTenant,
           y = OpsFedProgram/OpsTotal,
           color = County))+
  geom_jitter()+
  scale_color_manual(values = c("red4", "orange1", "lightpink","yellow", "blue", "hotpink", "cyan", "gold", "gray10","darkorchid", "mediumseagreen"))+
  facet_wrap(~County)+
  labs(title = "Ops w/ Federal Program ~ Tenant Operations",
       x = "Tenant Operations (%)",
       y = "Ops w/ Fed Program (%)")

ggplot(AggCenAg,
       aes(x = pTenant,
           y = OpsFedProgram/OpsTotal,
           color = OpsTotal))+
  geom_point()+
  geom_smooth()+
 labs(title = "Ops w/ Federal Program ~ Tenant Operations",
       x = "Tenant Operations (%)",
       y = "Ops w/ Fed Program (%)")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

Multivariate Correlations

Total Operations ~ BIPOC Residents + Land Area

p1 <- AggCenAg %>%
  plot_ly(x = ~pBipoc,
         z = ~ALAND,
         y = ~OpsTotal,
         color = ~MedianHHIncome,
         colors = c("gold", "blue"),
         text = ~County) %>%
  layout(title = 'Total Operations by BIPOC Residents and Land Area',
         scene = list(xaxis = list(tite = 'BIPOC Residents (%)'),
                      yaxis = list(title = 'Total Operations'),
                      zaxis = list(title = 'Land Area (m)')))
p1
## No trace type specified:
##   Based on info supplied, a 'scatter3d' trace seems appropriate.
##   Read more about this trace type -> https://plotly.com/r/reference/#scatter3d
## No scatter3d mode specifed:
##   Setting the mode to markers
##   Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode

Tenant Operations ~ BIPOC Residents + Median Household Income

p2 <- AggCenAg %>%
  plot_ly(x = ~pBipoc,
         z = ~MedianHHIncome,
         y = ~pTenant,
         color = ~MedianHHIncome,
         colors = c("green", "blue"),
         text = ~County) %>%
  layout(title = 'Tenant Operations by BIPOC Residents and Median Household Income',
         scene = list(xaxis = list(tite = 'BIPOC Residents (%)'),
                      yaxis = list(title = 'Tenant Operations (%)'),
                      zaxis = list(title = 'Median Household Income')))
p2
## No trace type specified:
##   Based on info supplied, a 'scatter3d' trace seems appropriate.
##   Read more about this trace type -> https://plotly.com/r/reference/#scatter3d
## No scatter3d mode specifed:
##   Setting the mode to markers
##   Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode
## Warning: Ignoring 2 observations

Ops w/ Federal Commodity Loans ~ BIPOC Residents + Tenant Operations

p3 <- AggCenAg %>%
  plot_ly(x = ~pBipoc,
         z = ~pTenant,
         y = ~OpsCCCLoans/OpsTotal,
         color = ~OpsTotal,
         colors = c("gold", "red"),
         text = ~County) %>%
  layout(title = 'Operations w/ Fed Commodity Loans by BIPOC Residents and Tenant Operations',
         scene = list(xaxis = list(tite = 'BIPOC Residents (%)'),
                      yaxis = list(title = 'Ops w/ Fed Commodity Loan (%)'),
                      zaxis = list(title = 'Tenant Operations (%)')))
p3
## No trace type specified:
##   Based on info supplied, a 'scatter3d' trace seems appropriate.
##   Read more about this trace type -> https://plotly.com/r/reference/#scatter3d
## No scatter3d mode specifed:
##   Setting the mode to markers
##   Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode

Ops w/ Federal Programs ~ BIPOC Residents + Tenant Operations

p4 <- AggCenAg %>%
  plot_ly(x = ~pBipoc,
         z = ~pTenant,
         y = ~OpsFedProgram/OpsTotal,
         color = ~OpsTotal,
         colors = c("blue", "red"),
         text = ~County) %>%
  layout(title = 'Operations w/ Federal Program by BIPOC Residents and Tenant Operations',
         scene = list(xaxis = list(tite = 'BIPOC Residents (%)'),
                      yaxis = list(title = 'Ops w/ Federal Program (%)'),
                      zaxis = list(title = 'Tenant Operations (%)')))
p4
## No trace type specified:
##   Based on info supplied, a 'scatter3d' trace seems appropriate.
##   Read more about this trace type -> https://plotly.com/r/reference/#scatter3d
## No scatter3d mode specifed:
##   Setting the mode to markers
##   Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode

Historical Ag Census Data

MIHistAg <- read.csv("~/R/SEMI_County_HistoricalCensus_MIState.csv")
#str(MIHistAg)
#View(MIHistAg)

ggplot(MIHistAg,
       aes(x = Year,
           y = Farms))+
  geom_point()+
  geom_smooth()+
  labs(title = "Number of Farms ~ Year",
       x = "Year",
       y = "Farms")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

ggplot(MIHistAg,
       aes(x = Year,
           y = AvgSize))+
  geom_point()+
  geom_smooth()+
  labs(title = "Average Size of Farms ~ Year",
       x = "Year",
       y = "Avg Size (acres^2")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

ggplot(MIHistAg,
       aes(x = Year,
           y = pOwner))+
  geom_point()+
  geom_smooth()+
  labs(title = "Full Ownership ~ Year",
       x = "Year",
       y = "Full Ownership (%)")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

ggplot(MIHistAg,
       aes(x = Year,
           y = pTenant))+
  geom_point()+
  geom_smooth()+
  labs(title = "Tenant Operations ~ Year",
       x = "Year",
       y = "Tenant Operations (%)")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

ggplot(MIHistAg,
       aes(x = Year,
           y = pBipocF))+
  geom_point()+
  geom_smooth()+
  labs(title = "BIPOC Farms ~ Year",
       x = "Year",
       y = "BIPOC Farms (%)")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

ggplot(MIHistAg,
       aes(x = Year,
           y = poBipocOwn))+
  geom_point()+
  geom_smooth()+
  labs(title = "BIPOC Farms Owned ~ Year",
       x = "Year",
       y = "BIPOC Farms Owned (% Total BIPOC Farms)")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).

ggplot(MIHistAg,
       aes(x = Year,
           y = poBipocTenant))+
  geom_point()+
  geom_smooth()+
  labs(title = "BIPOC Farm Tenancy ~ Year",
       x = "Year",
       y = "BIPOC Farm Tenancy (% Total BIPOC Farms)")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).

## Warning: Removed 1 rows containing missing values (geom_point).

ggplot(MIHistAg,
       aes(x = Year,
           y = pBipocTotalLand))+
  geom_point()+
  geom_smooth()+
  labs(title = "BIPOC Operated Land ~ Year",
       x = "Year",
       y = "BIPOC Operated Land (%)")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 2 rows containing non-finite values (stat_smooth).
## Warning: Removed 2 rows containing missing values (geom_point).

ggplot(MIHistAg,
       aes(x = Year,
           y = pWhiteF))+
  geom_point()+
  geom_smooth()+
  labs(title = "Total White Farms ~ Year",
       x = "Year",
       y = "White Farms (%)")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).

ggplot(MIHistAg,
       aes(x = Year,
           y = poWhiteOwner))+
  geom_point()+
  geom_smooth()+
  labs(title = "White Farms Owned ~ Year",
       x = "Year",
       y = "White Farm Ownership (% Total White Farms)")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).

## Warning: Removed 1 rows containing missing values (geom_point).

ggplot(MIHistAg,
       aes(x = Year,
           y = poWhiteTenant))+
  geom_point()+
  geom_smooth()+
  labs(title = "White Farm Tenancy ~ Year",
       x = "Year",
       y = "White Farm Tenancy (% Total White Farms)")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).

## Warning: Removed 1 rows containing missing values (geom_point).

ggplot(MIHistAg,
       aes(x = Year,
           y = pWhiteTotalLand))+
  geom_point()+
  geom_smooth()+
  labs(title = "White Operated Land ~ Year",
       x = "Year",
       y = "White Operated Land (%)")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 2 rows containing non-finite values (stat_smooth).
## Warning: Removed 2 rows containing missing values (geom_point).