Skip to content

Instantly share code, notes, and snippets.

View hrbrmstr's full-sized avatar
💤
#tired

boB Rudis hrbrmstr

💤
#tired
View GitHub Profile
---
title: "twee demo"
author: "Jenny Bryan"
date: "17 August, 2014"
output:
html_document:
toc: TRUE
keep_md: TRUE
---
doInstall <- TRUE
toInstall <- c("XML", "maps", "ggplot2", "sp")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
myURL <- "http://en.wikipedia.org/wiki/United_States_presidential_election,_2012"
allTables <- readHTMLTable(myURL)
str(allTables) # Look at the allTables object to find the specific table we want
stateTable <- allTables[[14]] # We want the 14th table in the list (maybe 13th?)
# This is the server logic for a Shiny web application.
# You can find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com
#
pkg <- c("shiny", "zipcode", "pbapply", "data.table", "dplyr",
"ggplot2", "grid", "gridExtra", "stringi", "magrittr")
new.pkg <- pkg[!(pkg %in% installed.packages())]
@hrbrmstr
hrbrmstr / shinyapp.sh
Last active October 3, 2016 21:45
Small script to help in creating one-click R+Shiny apps on OS X
#!/bin/bash
#
# v1.0 - Initial release - @hrbrmstr
#
# Script to turn a R+Shiny gist into a one-click OS X application
#
# Just enter in the gist ID and the app name you want, optionally providing
# a custom icns file and also optionally code-signing the built app
#
# It does rudimentary checking to ensure the gist id is, in fact a Shiny app.
@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")
@hrbrmstr
hrbrmstr / concisec.R
Last active July 21, 2018 21:46
Scrape security conference data from Concise Courses
library(rvest)
library(stringr)
library(dplyr)
library(readr)
extract <- function(doc, x) {
doc %>%
str_match_all(x) %>%
lapply(function(y) {
if (length(y)==0) {
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