Skip to content

Instantly share code, notes, and snippets.

View hrbrmstr's full-sized avatar
💤
#tired

boB Rudis hrbrmstr

💤
#tired
View GitHub Profile
@hrbrmstr
hrbrmstr / bubbles.R
Last active August 29, 2015 14:10
SO GIS thing
library(maptools)
library(mapproj)
library(rgeos)
library(rgdal)
library(ggplot2)
# for theme_map
devtools::source_gist("33baa3a79c5cfef0f6df")
# nice US map GeoJSON
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 3.
"Country Name","Country Code","Indicator Name","Indicator Code","1961","1962","1963","1964","1965","1966","1967","1968","1969","1970","1971","1972","1973","1974","1975","1976","1977","1978","1979","1980","1981","1982","1983","1984","1985","1986","1987","1988","1989","1990","1991","1992","1993","1994","1995","1996","1997","1998","1999","2000","2001","2002","2003","2004","2005","2006","2007","2008","2009","2010","2011","2012","2013","2014",
"Aruba","ABW","Population, total","SP.POP.TOTL","55435","56226","56697","57029","57360","57712","58049","58385","58724","59065","59438","59849","60239","60525","60655","60589","60366","60106","59978","60096","60567","61344","62204","62831","63028","62644","61835","61077","61032","62148","64623","68235","72498","76700","80326","83195","85447","87276","89004","90858","92894","94995","97015","98742","100031","100830","101219","101344","101418","101597","101932","102384","102911","",
"Andorra","AND","Population, total","SP.POP.TOTL","14376","15376","16410","17470","18551","19646
@hrbrmstr
hrbrmstr / choro.R
Last active August 29, 2015 14:10
SO Winkel Choro example
library(maptools)
library(mapproj)
library(rgeos)
library(rgdal)
library(ggplot2)
library(jsonlite)
library(RCurl)
# for theme_map
devtools::source_gist("33baa3a79c5cfef0f6df")
library(magrittr)
library(rvest)
library(data.table)
library(dplyr)
library(pbapply)
library(stringr)
fetch_attendance <- function(year=1990) {
url <- sprintf("http://www.baseball-reference.com/leagues/MLB/%s-misc.shtml", year)
html(url) %>% html_table %>% .[[1]] %>% mutate(year=year)
@hrbrmstr
hrbrmstr / dotdov
Created December 24, 2014 12:34
.gov domains with no SOA
511NY.GOV
ABILITYONE.FED.US
ACCESS-BOARD-MEMBERS.GOV
ADMONGO.GOV
ALADA.GOV
ALADNA.GOV
ANNUALCREDITREPORT.GOV
AZCORPCOM.GOV
AZCORPCOMM.GOV
BERRIENCOUNTY-MI.GOV
@hrbrmstr
hrbrmstr / foralex.R
Created December 24, 2014 17:54
foralex
library(rgdal)
library(rgeos)
library(maptools)
library(mapproj)
us <- readOGR("http://bl.ocks.org/mbostock/raw/4090846/us.json", "states")
proj4string(us) <- CRS("+proj=merc")
map <- fortify(us)
@hrbrmstr
hrbrmstr / latlon2country.R
Last active August 29, 2015 14:12
lat/lon coordinates to country name (or any adm level given proper shapefile)
library(rgdal)
library(magrittr)
# save this locally for realz
world <- readOGR("https://raw.githubusercontent.com/AshKyd/geojson-regions/master/data/source/ne_50m_admin_0_countries.geo.json", "OGRGeoJSON")
# assumes 'places' is a data.frame with at least lat/lon columns
places %>%
Gender Grade Age Race Urban/Rural School Goals Grades Sports Looks Money
boy 5 11 White Rural Elm Sports 1 2 4 3
boy 5 10 White Rural Elm Popular 2 1 4 3
girl 5 11 White Rural Elm Popular 4 3 1 2
girl 5 11 White Rural Elm Popular 2 3 4 1
girl 5 10 White Rural Elm Popular 4 2 1 3
girl 5 11 White Rural Elm Popular 4 2 1 3
girl 5 10 White Rural Elm Popular 3 4 1 2
girl 5 10 White Rural Elm Grades 3 4 2 1
girl 5 10 White Rural Elm Sports 3 2 1 4
@hrbrmstr
hrbrmstr / city-state-geo.R
Last active August 29, 2015 14:13
US City & State to lon/lat without using an API
library(rgeos)
library(rgdal)
library(httr)
library(dplyr)
geo_init <- function() {
try({
GET("http://www.mapcruzin.com/fcc-wireless-shapefiles/cities-towns.zip",
write_disk("cities.zip"))
Data sources:
CDC data on vaccine coverage: http://www.cdc.gov/flu/professionals/vaccination/reporti1112/reporti/index.htm
CDC data on current influenza situation: http://gis.cdc.gov/grasp/fluview/fluportaldashboard.html
Historical flu data: http://www.cdc.gov/flu/weekly/pastreports.htm
Locations of hospitals in Boston: https://data.cityofboston.gov/Public-Health/Hospital-Locations/46f7-2snz
NetLogo, a simple agent based model: http://ccl.northwestern.edu/netlogo/
Nemsis, emergency medical services API (haven't used this one myself): http://www.nemsis.org/v3/downloads/v3Archive.html
Written for R, but useful for epi basics in any language: cran.r-project.org/doc/contrib/Epicalc_Book.pdf
"Provides access to health statistics and information on hospital inpatient and emergency department utilization": http://hcupnet.ahrq.gov/
Healthcare Research and Quality data directory: http://www.ahrq.gov/data/dataresources.htm