suppressWarnings({library(ggplot2)
library(here)
library(tidyverse)
library(dplyr)
library(RColorBrewer)
})
## here() starts at C:/Users/Mary Jane Leach/OneDrive - Georgia Institute of Technology/Desktop/LAB_2/ENV_GIS
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ tibble 3.1.8 ✔ dplyr 1.0.10
## ✔ tidyr 1.2.1 ✔ stringr 1.5.0
## ✔ readr 2.1.3 ✔ forcats 0.5.2
## ✔ purrr 0.3.5
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
#Reading CSV
changeden <- read.csv(here("POPDEN.csv"))
head(changeden)
## OID_ BLOCKID10 SUM_BldgArea SUM_Volume FIRST_BlockArea FIRST_POP10
## 1 1 NA 1655596.84 192724405 NA NA
## 2 2 3.6061e+14 49842.17 2919403 127107 988
## 3 3 3.6061e+14 55791.02 2517849 140687 0
## 4 4 3.6061e+14 26029.82 3727707 262473 1344
## 5 5 3.6061e+14 46927.38 5946891 204529 726
## 6 6 3.6061e+14 179248.17 6524002 202652 0
## Shape_Length Shape_Area builtratio olddensity newdensity
## 1 56396.364 1655838.58 NA NA NA
## 2 4011.983 49849.80 0.3921277 0.007772979 0.01982257
## 3 1299.859 55799.57 0.3965613 0.000000000 0.00000000
## 4 1849.662 26033.80 0.0991714 0.005120527 0.05163310
## 5 1476.832 46934.57 0.2294412 0.003549619 0.01547071
## 6 2839.970 179275.67 0.8845122 0.000000000 0.00000000
#Dropping NAs
popden2 <- changeden %>% drop_na()
head(popden2)
## OID_ BLOCKID10 SUM_BldgArea SUM_Volume FIRST_BlockArea FIRST_POP10
## 1 2 3.6061e+14 49842.17 2919403.2 127107 988
## 2 3 3.6061e+14 55791.02 2517848.9 140687 0
## 3 4 3.6061e+14 26029.82 3727707.4 262473 1344
## 4 5 3.6061e+14 46927.38 5946890.8 204529 726
## 5 6 3.6061e+14 179248.17 6524001.6 202652 0
## 6 7 3.6061e+14 22190.52 880963.5 58409 0
## Shape_Length Shape_Area builtratio olddensity newdensity
## 1 4011.9832 49849.80 0.3921277 0.007772979 0.01982257
## 2 1299.8593 55799.57 0.3965613 0.000000000 0.00000000
## 3 1849.6620 26033.80 0.0991714 0.005120527 0.05163310
## 4 1476.8320 46934.57 0.2294412 0.003549619 0.01547071
## 5 2839.9697 179275.67 0.8845122 0.000000000 0.00000000
## 6 714.1983 22193.89 0.3799161 0.000000000 0.00000000
#Graph of population change, old vs. new
library(ggplot2)
popchange <- ggplot(data = popden2) +
geom_point(mapping = aes(x = olddensity, y = newdensity), color = "orange") +
coord_cartesian(xlim =c(0.00, 0.03), ylim = c(0.00, 0.2)) +
labs(x = "Population density by census block area (people/sq. ft.)",
y = "Population density by building area (people/sq. ft.)",
color = "Population",
title = "Difference in the Population Density of Census Blocks vs. that of “Livable Area")
popchange
```