From aec36d483ed819006675b2e2fb7cdc515c32a5bc Mon Sep 17 00:00:00 2001 From: djbarnes24601 <70548925+djbarnes24601@users.noreply.github.com> Date: Tue, 27 Oct 2020 18:51:26 -0800 Subject: [PATCH] Create hackForCA_prisons.Rmd --- .../explore-data/hackForCA_prisons.Rmd | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 proximity-app/explore-data/hackForCA_prisons.Rmd diff --git a/proximity-app/explore-data/hackForCA_prisons.Rmd b/proximity-app/explore-data/hackForCA_prisons.Rmd new file mode 100644 index 0000000..db51a88 --- /dev/null +++ b/proximity-app/explore-data/hackForCA_prisons.Rmd @@ -0,0 +1,49 @@ +--- +title: "HackforCA:Toxic Prisons" +author: "Deckard Barnes" +date: "10/25/2020" +output: html_document +--- + +```{r} +library(tidyr) +library(dplyr) +library(ggplot2) +``` + +Load the prison boundaries dataset + +```{r} +prisons <-read.csv("/Users/Decka/Downloads/Prison_Boundaries.csv") +``` + +```{r} +head(prisons) #quick overview of the dataset +glimpse(prisons) +``` + +Many missing values for prison Populations in this dataset +```{r} +#Missing values in this dataset are coded as -999 +prisons %>% + select(STATE, POPULATION) + +#Finding the total prison population +prisons %>% + filter(POPULATION != -999) %>% + summarize(total_pop = sum(POPULATION)) +``` + + + +Count the number of missing values for population per state +```{r} +prisons %>% + #filter for rows containing null values(-999) + filter(POPULATION == -999) %>% + #group by state + group_by(STATE) %>% + #count the number of missing values in each state and sort(desc) + count(sort = TRUE) +``` +