diff --git a/Data/Pop_1990s.xls b/Data/Pop_1990s.xls new file mode 100644 index 0000000..d8d219d Binary files /dev/null and b/Data/Pop_1990s.xls differ diff --git a/Scripts/Data_Load.r b/Scripts/Data_Load.r index af2147d..88a4851 100644 --- a/Scripts/Data_Load.r +++ b/Scripts/Data_Load.r @@ -1,6 +1,6 @@ library(rvest) library(tidyverse) - +library(readxl) ########County, Death, Birth and Migration Data #Data found on the page http://eadiv.state.wy.us/pop/ @@ -110,21 +110,14 @@ CITY_POP <- rbind(CITY_TBL,CITY_POP) CITY_POP$City <- gsub("LaGrange","La_Grange",CITY_POP$City) COUNTY_POP <- rbind(COUNTY_TBL,COUNTY_POP) ####################County and City Population DAta for 1990-2000 -PAGE <- read_html('http://eadiv.state.wy.us/pop/c&sc90_00.htm') -NODE <- html_element(PAGE ,"body") -TEST <- read_table(html_text2(NODE),skip=21,skip_empty_rows=TRUE) -TO_ADJ <- sum((!is.na(TEST[2,])))-11 - -?read_table -?html_text2 -?html_text -TBL <- html_table(NODE) -TBL - -ST <- which(toupper(TBL$X1)==toupper("Albany Cnty")) -END <- which(toupper(TBL$X1)==toupper("Balance of Weston County")) - - - +if(!file.exists("./Data/Pop_1990s.xls")){download.file('http://eadiv.state.wy.us/pop/c&sc90_00.xls',"./Data/Pop_1990s.xls")} +TEMP <- read_xls("Data/Pop_1990s.xls",skip=2)[-1:-4,] +colnames(TEMP)[1] <- "County" +tail(TEMP) +TEMP <- TEMP[1:which(TEMP[,1]=="Wind River Res."),] +TEMP <- pivot_longer(TEMP,all_of(colnames(TEMP)[-1]),names_to="Year",values_to="Population") %>% mutate(Year=as.integer(Year),Population=as.numeric(Population)) +TEMP_COUNTY <- TEMP[grepl("Cnty",TEMP %>% pull(County),ignore.case=TRUE),] +TEMP_CITY <- TEMP[grep("Cnty",TEMP %>% pull(County),ignore.case=TRUE,invert=TRUE),] +TEMP_CITY