Skip to content

Instantly share code, notes, and snippets.

Avatar

Josh Errickson josherrickson

View GitHub Profile
View install_R_deps.sh
#!/bin/bash
echo "i <- rownames(installed.packages())" > __tmp__.R
grep -oh --include=\*.{Rmd,R} -r * -e "\(library\|require\)([A-Za-z0-9.]\+)" | \
sed 's_library(_"_' | \
sed 's_require(_"_' | \
sed 's_)_",_' | sort | uniq | \
perl -p -e 's/\n/ /' | \
sed 's_^_new <- c(_' | \
@josherrickson
josherrickson / colmean
Last active Feb 20, 2018
Awk script to compute the mean of a csv file's column.
View colmean
#!/bin/bash
SEP=","
HEADER=true
STDERR=false
while [ "$#" -gt 0 ]; do
case "$1" in
-s) SEP="$2"; shift 2;;
-c) COL="$2"; shift 2;;
View how_many_imputations.R
# This gist has been superceded by the howManyImputations package (https://github.com/josherrickson/howManyImputations).
@josherrickson
josherrickson / ggheatmap.R
Last active Mar 8, 2017
ggheatmap - Create a heatmap in ggplot2
View ggheatmap.R
library(dplyr)
library(reshape2)
library(ggplot2)
#' Create a heatmap in ggplot2
#'
#' @param data Data set
#' @param print.cors Default TRUE. Should the correlations be printed in each block of the heatmap?
#' @param reoder Default TRUE. Should the entries be re-ordered via clustering, similar to `heatmap`?
#' @param colors Default c("red", "white", "blue"). Vector of length three defining colors for correaltions (1, 0, -1).
#'