Skip to content

Instantly share code, notes, and snippets.

@apreshill
apreshill / ipak.R
Created March 25, 2016 04:42 — forked from stevenworthington/ipak.R
Install and load multiple R packages at once
# ipak function: install and load multiple R packages.
# check to see if packages are installed. Install them if they are not, then load them into the R session.
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
# convert all column names to snake case
# make all column names lower case
# replace all . with _
names2snake <- function(data){
require(stringr)
require(dplyr)
names(data) = names(data) %>%
tolower() %>%
str_replace_all(., "[.]", "_")
data
county sample state name exceedances
Mobile 20 al Dauphin Island Water & Sewer 1
Monroe 23 al Excel Water System 1
Washington 95 al Tate & Lyle Sucralose, Inc. Water System 1
Coosa 18.3 al Lake Mitchell Water, Incorporated 1
Juneau City and Borough 15.5 ak Thunder Mountain Mobile Park 1
Juneau City and Borough 31 ak Hecla Greens Creek Hawk Inlet 1
Ketchikan Gateway Borough 27.7 ak Boyer Towing 1
Ketchikan Gateway Borough 32.9 ak Thorne Bay, City Of 1
Ketchikan Gateway Borough 16.2 ak Clover Pass Christian School 2
@apreshill
apreshill / cdc_addm_all.csv
Last active April 1, 2016 17:30
Prevalence of ASD in the US from most recent 4 CDC ADDM surveys
site total n_asd prevalence_1000 data_source l95_1000 u95_1000 year_survey year_pub birth_cohort table for_line
Alabama 36566 174 4.8 ho 4.1 5.5 2008 2012 2000 2 1
Arizona 32601 507 15.6 eh 14.3 17 2008 2012 2000 2 1
Arkansas 4940 52 10.5 eh 8 13.8 2008 2012 2000 2 1
Colorado 7725 91 11.8 eh 9.6 14.5 2008 2012 2000 2 0
Colorado 29336 188 6.4 ho 5.6 7.4 2008 2012 2000 2 1
Florida 29366 211 7.2 ho 6.3 8.2 2008 2012 2000 2 1
Georgia 50427 601 11.9 eh 11 12.9 2008 2012 2000 2 1
Maryland 27022 336 12.4 eh 11.2 13.8 2008 2012 2000 2 1
Missouri 25668 357 13.9 ho 12.5 15.4 2008 2012 2000 2 1