From 06b8a858e2efae78082bc844e598ccc3362782b9 Mon Sep 17 00:00:00 2001 From: Alex Gebben Work Date: Thu, 30 Oct 2025 16:58:53 -0600 Subject: [PATCH] Wokring on age comparison in Kemmerer and Lincoln --- 2_Result_Analysis.r | 3 ++- Zip_Code.r | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 Zip_Code.r diff --git a/2_Result_Analysis.r b/2_Result_Analysis.r index 56397a5..10c6140 100644 --- a/2_Result_Analysis.r +++ b/2_Result_Analysis.r @@ -24,5 +24,6 @@ YEARS <- 2023:(2023+NUM_YEARS_PROJECTED) GRAPH_DATA$Percentile <- factor(GRAPH_DATA$Percentile,levels=rev(c('2.5%','5%','10%','25%','40%','60%','75%','90%','95%','97.5%'))) GRAPH <- ggplot(data=GRAPH_DATA)+geom_ribbon(data=FAN_DATA,aes(x=Year,ymin=`2.5%`,ymax=`97.5%`),alpha=ALPHA,fill=COLOR)+geom_ribbon(data=FAN_DATA,aes(x=Year,ymin=`5%`,ymax=`95%`),alpha=ALPHA,fill=COLOR)+geom_ribbon(data=FAN_DATA,aes(x=Year,ymin=`10%`,ymax=`90%`),alpha=ALPHA,fill=COLOR)+geom_ribbon(data=FAN_DATA,aes(x=Year,ymin=`25%`,ymax=`75%`),alpha=ALPHA,fill=COLOR)+geom_ribbon(data=FAN_DATA,aes(x=Year,ymin=`40%`,ymax=`60%`),alpha=ALPHA,fill=COLOR)+geom_line(aes(x=Year,y=Population,group=Percentile,color=Percentile))+geom_line(data=HIST,aes(x=Year,y=Population),color='black',size=0.75)+geom_line(data=MEDIAN_PRED,aes(x=Year,y=Population),color='black',linetype=4,size=0.75)+ scale_x_continuous(breaks = c(seq(1940, 2070, by = 10)))+ scale_y_continuous(breaks = seq(0, 35000, by = 5000))+theme_bw()+ggtitle("Lincoln County, Wyoming Population Forecast") GRAPH -ggsave("Lincoln_Forecast.png",GRAPH) +length(RES$SIM_ID %>% unique) +ggsave(Lincoln_Forecast.png",GRAPH) diff --git a/Zip_Code.r b/Zip_Code.r new file mode 100644 index 0000000..ac15634 --- /dev/null +++ b/Zip_Code.r @@ -0,0 +1,44 @@ +library(tidyverse) +library(tidycensus) +library(zipcodeR) +KEY <- '30e13ab22563318ff59286e433099f4174d4edd4' +TRACTS <- get_tracts(search_city('Diamondville','WY')$zipcode) %>% full_join(get_tracts(search_city('Kemmerer','WY')$zipcode)) +TRACTS +census_api_key(KEY, install = TRUE) +vars <- c("P2_002N") +get_decennial(geography="tract",variables=vars,state='WY',county='lincoln',GEOID='56023978400') +vars <- c("B01001_004","B01001_005") + +get_acs(geography="tract",variables=vars,state='WY',county='lincoln',GEOID='56023978400') +######MALE +VARS <-c( +#Under_Five +'B01001_003E', +#5-9 +'B01001_004E', +#10-14 +'B01001_005E', +#15-17 +'B01001_006E', +#18-19 +'B01001_007E', +#20 +'B01001_008E', +#21 +'B01001_009E', +#22-24 +'B01001_010E', +#25-29 +'B01001_011E', +#85+ +'B01001_025E') +TEMP <- get_acs(geography="tract",variables=VARS,state='WY',county='lincoln') +KEM <- TEMP %>% filter(GEOID=='56023978400') +KEM +19/sum(KEM$estimate) + +LN <- TEMP %>% filter(GEOID!='56023978400') +LN +19/sum(KEM$estimate) + +