Skip to content

Instantly share code, notes, and snippets.

@jebyrnes
Created November 5, 2019 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jebyrnes/4f5340d21c5790fbd91da5ab728bcc76 to your computer and use it in GitHub Desktop.
Save jebyrnes/4f5340d21c5790fbd91da5ab728bcc76 to your computer and use it in GitHub Desktop.
A quick interactive map of biking for #tidytuesday
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