#Import libraries
library(sf)
library(tidyr)
library(ggplot2)
#Import data
fname_output <- '../scratch/Hexagons_from_R.shp'
fcHex <- st_read(fname_output,quiet=TRUE)
#Extract dataframe
dfHex <- as.data.frame(fcHex)
#Tidy the data for plotting
dfHex2 <- dfHex %>%
select(c('NeedTotal','OppsTotal')) %>%
pivot_longer(c('NeedTotal','OppsTotal'),
names_to='Type',
values_to='Count')
#Histograms
ggplot(dfHex2, aes(x=Count,fill=Type)) +
geom_histogram(binwidth=1, alpha=0.5, position="dodge")
#Density plots
ggplot(dfHex2, aes(x=Count, colour=Type)) + geom_density()