Skip to content

Instantly share code, notes, and snippets.

View sachsmc's full-sized avatar

Michael Sachs sachsmc

View GitHub Profile
@sachsmc
sachsmc / .block
Last active February 17, 2016 18:00
US Budget Proposal Data 2017
license: mit
@sachsmc
sachsmc / .block
Last active February 15, 2016 19:31
DC Moving Violations Feb 2010
license: mit
@sachsmc
sachsmc / .block
Last active February 15, 2016 19:30
DC Vision Zero Crash Data
license: gpl-3.0
@sachsmc
sachsmc / .block
Last active February 17, 2016 18:21
Scrape your personal Capital Bikeshare Trip data
license: mit
@sachsmc
sachsmc / Submit to biowulf
Last active August 29, 2015 14:21
MPI Apply on Biowulf
qsub -v np=52 -l walltime=424:00:00, nodes=26 simRun.bat
@sachsmc
sachsmc / man-legend.R
Last active May 29, 2018 21:36
Add manual legend in ggplot2
tm <- data.frame(Marker = sort(rep(letters[1:5], 10)), x = runif(50), y = runif(50))
p1 + geom_line(data = tm, aes(linetype = Marker, x = x, y = y), alpha = 0) +
scale_linetype(guide = guide_legend(override.aes = list(alpha = 1)), labels =
c(expression(A[1]), expression(A[2]), expression(A[3]), expression(A[4]), expression(A[5]))) +
theme(legend.position = c(.75, .25))
@sachsmc
sachsmc / example.Rmd
Created November 14, 2014 18:13
Sparklificator in rmarkdown
---
title: "Sparklify"
author: "Michael Sachs"
date: "November 14, 2014"
output:
html_document:
self_contained: false
---
<head>
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
@sachsmc
sachsmc / Rjobs
Last active August 29, 2015 14:09
Parallel Jobs on Biowulf
Rscript --vanilla run.R 1 > run-1.Rout
Rscript --vanilla run.R 2 > run-2.Rout
Rscript --vanilla run.R 3 > run-3.Rout
Rscript --vanilla run.R 4 > run-4.Rout
Rscript --vanilla run.R 5 > run-5.Rout
Rscript --vanilla run.R 6 > run-6.Rout
Rscript --vanilla run.R 7 > run-7.Rout
Rscript --vanilla run.R 8 > run-8.Rout
Rscript --vanilla run.R 9 > run-9.Rout
Rscript --vanilla run.R 10 > run-10.Rout
@sachsmc
sachsmc / freq-approach.R
Created August 20, 2014 14:28
frequentist approach
## frequentist approach for comparison
freq_leaveout <- function(formula) {
leftout <- sapply(1:n.trials, function(i){
fit.biv <- lm(formula, data = hat.test[-i, ])
predict(fit.biv, newdata = hat.test)[i]
})
@sachsmc
sachsmc / ddplyWithTotals.R
Created February 5, 2014 02:24
ddplyWithTotals.R
##############################################################
## Author: Michael Sachs, michael.sachs@nih.gov
## Version 1.0
## Date Updated: 9/16/2013
# Description: An extension of the ddply function from the
# plyr package that additionally evaluates the user-supplied
# function on subsets defined by lower-order combinations of the
# variables. This is useful for calculating sub-totals and totals.