Skip to content

Instantly share code, notes, and snippets.

View mattsigal's full-sized avatar

Matthew Sigal mattsigal

View GitHub Profile
@mattsigal
mattsigal / stratifiedNorm.R
Last active August 29, 2015 14:11
Create Stratified Norm Sample from Strata and Count Vector
#' Function to draw observations from stratified norm sample
#'
#' This function creates a stratified random sample, given an arbitrary number of
#' factors and levels within those factors.
#'
#' @param dat data.frame object
#' @param strata character; a named vector indicating the strata variables
#' @param observations numeric; number of cases to sample from each strata
#' @param return.grid logical; return grid of factor combintions?
#' @param full.data logical; return the original dataset with a new logical
@mattsigal
mattsigal / Transformations
Created October 21, 2013 18:55
Simple example of transforming data/scale/coordinate system in ggplot2.
library(ggplot2)
# Sample diamonds dataframe:
didat <- diamonds[sample(nrow(diamonds), 1000), ]
# Original data:
ggplot(didat, aes(x = depth, y = price)) + geom_point()
# Transform data:
ggplot(didat, aes(x = log10(depth), y = log10(price))) + geom_point()
@mattsigal
mattsigal / index.html
Last active December 25, 2015 21:19
Highcharts
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='http://code.jquery.com/jquery-1.9.1.min.js' type='text/javascript'></script>
<script src='http://code.highcharts.com/highcharts.js' type='text/javascript'></script>
<script src='http://code.highcharts.com/highcharts-more.js' type='text/javascript'></script>
<script src='http://code.highcharts.com/modules/exporting.js' type='text/javascript'></script>