Created
November 5, 2019 19:10
-
-
Save jebyrnes/4f5340d21c5790fbd91da5ab728bcc76 to your computer and use it in GitHub Desktop.
A quick interactive map of biking for #tidytuesday
This file contains 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(ggmap) | |
library(sf) | |
library(tmap) | |
#whereami? | |
here::here() | |
#get my apis flowin' | |
register_google(readLines("~/goog.api")) | |
# #download the data and add geocoding | |
# #note: this takes a while, so, do this once, | |
# #then work on the data it writes out | |
# commute_mode <- readr::read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-11-05/commute.csv") | |
# | |
# commute_mode <- commute_mode %>% | |
# cbind(geocode(paste(commute_mode$city, commute_mode$state, sep = ","))) | |
# | |
# commute_mode_sf <- commute_mode %>% | |
# st_as_sf(coords = c("lon", "lat"), remove=FALSE) | |
# | |
# saveRDS(commute_mode_sf, "../data/acs_bike_commute_tidy_sf.RDS") | |
commute_mode_sf <- readRDS("../data/acs_bike_commute_tidy_sf.RDS") | |
ggplot(commute_mode_sf, aes(size = n)) + geom_sf(alpha = 0.1) + facet_wrap(~mode) | |
tmap_mode("view") | |
tm_basemap("Stamen.Watercolor") + | |
tm_shape(commute_mode_sf %>% filter(mode == "Bike"), | |
name = "No. people and % of City Biking") + | |
tm_bubbles(size = "n", col = "percent", | |
title.col = "Percent Biking") + | |
tm_tiles("Stamen.TonerLabels") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment