Working on 1990's
This commit is contained in:
parent
b5e715400e
commit
5c1ad7185f
BIN
Data/Pop_1990s.xls
Normal file
BIN
Data/Pop_1990s.xls
Normal file
Binary file not shown.
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user