Skip to content

Instantly share code, notes, and snippets.

@stillmatic
stillmatic / graphdata.json
Last active August 29, 2015 14:04
loading grouped graph data from json
[
{
"x": "2014-06-11",
"y": 20,
"group": 1
},
{
"x": "2014-06-12",
"y": 25,
"group": 1
#2012
load("C:/120/wptp/sesh1.RData")
attach(newdata);
with(newdata, plot(I.formed.a.positive.relationship.with.my.tutee.. ~ Semesters))
with(newdata, plot(Semesters ~ Academic.Year))
with(newdata, plot(Are.you.a.section.leader. ~ Academic.Year))
.f = function(
lm(Tutor.at.the.same.site ~ My.tutee.benefited.from.tutoring.sessions..)
#Intercept: 0.1694 Coeff: 0.1565
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../paper-item/paper-item.html">
@stillmatic
stillmatic / baseball.r
Last active August 29, 2015 14:19
employ lahman library and build model for hall of fame election
# mlb hall of fame classification analysis
# chua@wharton.upenn.edu
# attempt to follow https://google-styleguide.googlecode.com/svn/trunk/Rguide.xml
rm(list=ls())
par(mfrow=c(1,1))
if (!require("pacman")) install.packages("pacman")
pacman::p_load("Lahman", "dplyr", "ggplot2")
@stillmatic
stillmatic / pitcherVis.r
Created April 28, 2015 04:17
compare pre and post 1950 pitchers
# chua@wharton.upenn.edu
## my cached version may be slightly different than the live version loaded by this file
if (!require("pacman")) install.packages("pacman")
pacman::p_load("Lahman", "dplyr")
batting <- summarize(group_by(Batting, playerID),
ab=sum(AB, na.rm=TRUE), r=sum(R, na.rm=TRUE),
h=sum(H, na.rm=TRUE), x2b=sum(X2B, na.rm=TRUE),
x3b=sum(X3B, na.rm=TRUE), hr=sum(HR, na.rm=TRUE),
@stillmatic
stillmatic / clean-hitters.r
Last active August 29, 2015 14:20
lahman get started code
# mlb hall of fame classification analysis
# chua@wharton.upenn.edu
rm(list = ls())
par(mfrow = c(1, 1))
if (!require("pacman")) install.packages("pacman")
pacman::p_load("Lahman", "dplyr", "ggplot2")
# get career batting totals
@stillmatic
stillmatic / grids.r
Last active August 29, 2015 14:23
r - square gridding
# simple utility function to plot a bunch of graphs in a square-ish fashion
findOptArrangement <- function(k) {
# k: number of plots to arrange
# given k, find most square-like arrangement of the data
s <- sqrt(k)
f <- floor(s)
if(s %% 1 == 0 ) {
par(mfrow=c(s,s))
} else {
@stillmatic
stillmatic / osx_notification.R
Created July 28, 2016 04:24
Wrapper function to easily throw notifications on OS X.
#' Wrapper function to throw OS X notifications.
#'
#' @title OSX notifier
#' @author \href{https://github.com/stillmatic}{Chris Hua}
#'
#' @param message Body text of notification
#' @param title Title of notification
#' @param sound Optional. Valid sounds are in `~/Library/Sounds` or `/System/Library/Sounds`
#'
#' @return an AppleScript notification
@stillmatic
stillmatic / slide_apply.r
Last active August 12, 2016 04:37
Like zoo::rollapply but faster
##########
#' Applies a function to subsets of a given dataset.
#' Note: sets values without sufficient data to NA.
#' Using 'step' is particularly useful for leave-one-out analysis.
#'
#' @export
#' @name slide_apply
#' @author \href{https://github.com/stillmatic}{Chris Hua}
#' @title Use apply over a sliding window of data
#' @param data Array of data to apply the function over.

Keybase proof

I hereby claim:

  • I am stillmatic on github.
  • I am hua (https://keybase.io/hua) on keybase.
  • I have a public key whose fingerprint is 6334 1815 CDA1 CE92 9D08 90F8 1EA6 17AD CD6D 0FBF

To claim this, I am signing this object: