Skip to content

Instantly share code, notes, and snippets.

@statzhero
statzhero / server.R
Created January 15, 2014 12:15 — forked from pssguy/server.R
# libraries used. install as necessary
library(shiny)
library(RJSONIO) # acquiring and parsing data
library(ggplot2) # graphs
library(plyr) # manipulating data
library(lubridate) #dates
library(stringr)
trim.leading <- function (x) sub("^\\s+", "", x)
@statzhero
statzhero / gist:8217552
Created January 2, 2014 10:48
R gist for creating a few random IQ scores (credit R. Burns)
iqcor <- matrix(.5, nrow=2, ncol=2)
diag(iqcor) <- 1
iqcor
require(MASS)
mvrnorm(10, mu=c(100, 100), Sigma=100*iqcor)
@statzhero
statzhero / mbox-regex
Created August 20, 2013 14:12
A regular expression that finds email addresses saved in a Apple Mail mbox file. \+ is omitted.
grep -Eiorh '[a-zA-Z]{1}[a-zA-Z0-9_\.\-]{1,26}@[a-zA-Z0-9_\.\-]+\.(?:[a-zA-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)$' mbox | sort | uniq > emails.txt
@statzhero
statzhero / row-sample
Last active July 13, 2017 04:45
A function to make analysing a random subset easier.
row.sample <- function(dta, rep = 20) {
dta <- as.data.frame(dta) # for single variables
dta[sample(1:nrow(dta), rep, replace=FALSE), ]
}