forked from CreatingData/Historical-Populations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
First parsing.Rmd
42 lines (28 loc) · 1.33 KB
/
First parsing.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
---
title: "R Notebook"
output: html_notebook
---
This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Cmd+Shift+Enter*.
```{r}
library(tidyverse)
library(stringr)
counties = read_tsv("Gaz_counties_national.txt") %>% mutate(county = GEOID)
subcounties = read_tsv("2016_Gaz_cousubs_national.txt") %>% mutate(county=str_sub(GEOID,0,5))
subcounties %>% select(county)
county_names = counties %>% select(county,county_name = NAME)
subcounties %>% inner_join(county_names)
files = list.files("wiki_census",pattern = ".csv",full.names = T)
files = files[!grepl("Counties2014",files)]
csvs = lapply(files,function(f) read_csv(f))
c = csvs[1]
c %>% gather(year,count,-Geography)
c
c %>% mutate()
state = read_csv("wiki_census/ALPlaces.csv")
subcounties %>%
filter(USPS=="NJ") %>%
ggplot() + geom_point(aes(y=INTPTLAT,x=INTPTLONG,color=county)) + coord_map()
```
Add a new chunk by clicking the *Insert Chunk* button on the toolbar or by pressing *Cmd+Option+I*.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the *Preview* button or press *Cmd+Shift+K* to preview the HTML file).