This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Loading ERA5 data in Python and processing with R" | |
format: html | |
editor: visual | |
editor_options: | |
chunk_output_type: console | |
--- | |
```{r setup} | |
library(Rarr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
US Senate (Vote For 1) | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Herschel Junior Walker (Rep) | Raphael Warnock (I) (Dem) | Chase Oliver (Lib) | ||||||||||||||||
County | Registered Voters | Election Day Votes | Absentee by Mail Votes | Advance Voting Votes | Provisional Votes | Total Votes | Election Day Votes | Absentee by Mail Votes | Advance Voting Votes | Provisional Votes | Total Votes | Election Day Votes | Absentee by Mail Votes | Advance Voting Votes | Provisional Votes | Total Votes | Total | |
Appling | 0 | 2569 | 224 | 2550 | 0 | 5343 | 411 | 155 | 694 | 0 | 1260 | 28 | 4 | 33 | 0 | 65 | 6668 | |
Atkinson | 0 | 866 | 33 | 807 | 0 | 1706 | 189 | 22 | 291 | 0 | 502 | 15 | 2 | 10 | 0 | 27 | 2235 | |
Bacon | 0 | 829 | 74 | 2301 | 0 | 3204 | 134 | 41 | 283 | 0 | 458 | 17 | 6 | 25 | 0 | 48 | 3710 | |
Baker | 0 | 352 | 35 | 322 | 2 | 711 | 163 | 87 | 272 | 4 | 526 | 7 | 0 | 4 | 1 | 12 | 1249 | |
Baldwin | 0 | 2717 | 296 | 4403 | 0 | 7416 | 2163 | 818 | 4343 | 0 | 7324 | 107 | 20 | 87 | 0 | 214 | 14954 | |
Banks | 0 | 2275 | 186 | 3887 | 0 | 6348 | 242 | 84 | 446 | 0 | 772 | 71 | 11 | 77 | 0 | 159 | 7279 | |
Barrow | 0 | 8934 | 662 | 10531 | 0 | 20127 | 3007 | 691 | 4534 | 0 | 8232 | 450 | 43 | 400 | 0 | 893 | 29252 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(tmap) | |
library(sf) | |
ctytax<-read_csv("countyinflow1920.csv") %>% | |
mutate(ctyfips1=paste(y1_statefips,y1_countyfips,sep=""), | |
ctyfips2=paste(y2_statefips,y2_countyfips,sep="")) | |
counties<-tigris::counties() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(extrafont) | |
library(sf) | |
ebird<-read_csv("ebird_GA_Sep2019.csv") #Individual observation data | |
species<-ebird %>% | |
distinct(`COMMON NAME`) | |
species_blue<-species %>% | |
filter(str_detect(tolower(`COMMON NAME`),"blue")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Code adapted from https://github.com/datawookie/travelling-salesman-map/blob/master/travelling-salesman-demo.R | |
library(tidyverse) | |
library(purrr) | |
library(ggmap) | |
library(gmapsdistance) | |
library(TSP) | |
library(sf) | |
# Due to changes in the Google Maps Terms of Service, this code will not work without first registering an API key. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidycensus) | |
library(tidyverse) | |
library(sf) | |
#Select variables | |
v18<-load_variables(2018,"acs5",cache=TRUE) | |
vars<-v18 %>% | |
filter(substr(name,1,6) %in% c("B25064","B03002","B25106","B19013")) | |
#write_csv(vars,"data/census_vars.csv") #Select just those variables I want | |
vars_sel<-read_csv("data/census_vars.csv") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(covdata) | |
library(tmap) | |
library(TTR) | |
ga_mobility<-apple_mobility %>% | |
filter(sub_region=="Georgia" & geo_type=="county" & | |
is.na(index)==FALSE) %>% | |
group_by(region) %>% | |
mutate(ra = runMean(index, 5)) %>% ###Create a five day moving average |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(ggrepel) | |
library(gghighlight) | |
library(tidycensus) | |
library(sf) | |
dailydata<-read_csv("https://github.com/nytimes/covid-19-data/raw/master/us-counties.csv") | |
#This next step requires a census API | |
cty_pop<-get_acs(geography="county",variables = "B01001_001",geometry=TRUE) %>% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import path | |
from PIL import Image | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import os | |
from wordcloud import WordCloud, STOPWORDS | |
d = path.dirname(__file__) if "__file__" in locals() else os.getcwd() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(sf) | |
#Join population data to tract boundaries and convert to point coordinates | |
tractdata<-read_csv("nhgis0105_2017_tract_racepov.csv") #Data on population downloaded from NHGIS | |
tracts<-st_read("nhgis0101_shapefile_tl2017_us_tract_2017/US_tract_2017.shp",stringsAsFactors=FALSE) %>% #Tract boundaries downloaded from NHGIS | |
st_transform(4326) | |
tract_center<-tracts %>% | |
st_centroid() %>% | |
st_coordinates() %>% |
NewerOlder