P. Mae Cooper
6/8/2020
library(tidycensus)
vars<- c("B28002_001","B28002_013","S1701_C03_002","DP05_0018","DP05_0077P","DP05_0078P","DP05_0079P","DP05_0080P","DP05_0071P")
nms<- c("TOTPOP","NOINT","POVPCT","MEDAGE","WHT","BLK","IND","ASN","HSP")
county18<-get_acs("county",survey = "acs1", key = "993d02931a941bd1f5af535c637800916aa504b2",variables=vars)
cty18_wide<-data.frame(county18$GEOID[county18$variable==vars[1]],
county18$NAME[county18$variable==vars[1]])
for(i in 1:9){
cty18_wide[i+2]<-county18$estimate[county18$variable==vars[i]]}
names(cty18_wide)<-c("GEOID","NAME",nms)
cty18_wide$INTPCT<- with(cty18_wide,round((1-(NOINT/TOTPOP))*100,1))
y<-cty18_wide$INTPCT
x<-cty18_wide$POVPCT
fit<- lm(y ~ x)
plot(x=x,y=y,xlab="Percent of children in Poverty",ylab="Percent of Households with Home Internet")
abline(fit)