Skip to content

Instantly share code, notes, and snippets.

View brentonk's full-sized avatar

Brenton Kenkel brentonk

View GitHub Profile
@brentonk
brentonk / clean-maddison.r
Created June 1, 2016 19:59
Download and tidy the Maddison Project GDP data
################################################################################
### Download and tidy the Maddison Project GDP data
###
### Converts country names to ISO via the regex in the countrycode package
################################################################################
library("countrycode")
library("plyr")
library("dplyr")
library("readxl")
@brentonk
brentonk / # r - 2016-05-12_09-56-37.txt
Created May 12, 2016 14:58
r (homebrew/science/r) on Mac OS X 10.11.4 - Homebrew build logs
Homebrew build logs for homebrew/science/r on Mac OS X 10.11.4
Build date: 2016-05-12 09:56:37
@brentonk
brentonk / charter-template.tex
Created January 12, 2016 15:55
Simple Charter template for Pandoc
\documentclass[12pt,svgnames]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{sectsty}
\usepackage{float}
\usepackage[labelsep=period,font=small,labelfont=bf]{caption}
@brentonk
brentonk / pkgs.r
Created March 31, 2015 13:41
Packages to install after updating R
## Packages to install after updating R
install.packages(c(
## Hadleyverse
"devtools",
"dplyr",
"ggplot2",
"plyr",
"reshape2",
"stringr",
@brentonk
brentonk / bktheorem.tex
Created March 12, 2015 15:04
My standard theorem style
\usepackage{thmtools}
\usepackage{thm-restate}
\declaretheoremstyle[%
headfont=\sffamily\bfseries,
bodyfont=\itshape,
spaceabove=1.1em,
spacebelow=1.1em
]{bktheorem}
@brentonk
brentonk / tikz-emacs.md
Last active August 29, 2015 13:58
Getting tikzDevice to play nice with Emacs

I've recently run into a problem running R scripts that use the tikzDevice package from within Emacs. The problem is the same whether I run them from a terminal inside Emacs or via ESS. Calling tikz() yields an error message like

! Missing = inserted for \ifnum.
<to be read again> 
                   -
l.6 
     
Here is how much of TeX's memory you used:
 9161 strings out of 493485
@brentonk
brentonk / gist:3537080
Created August 30, 2012 18:39
AUCTeX code for restatable environment
(LaTeX-add-environments
'("restatable" LaTeX-env-args
(TeX-arg-key-val LaTeX-environment-list)
"Name"))
@brentonk
brentonk / partitions.r
Created June 5, 2010 08:44
Create set of all partitions from a vector in R
## create set of all partitions from a vector
## based on code and algorithm at http://compprog.wordpress.com/2007/10/15/generating-the-partitions-of-a-set/
## slow for vectors of length > 8, but gets the job done
nextOrder <- function(s)
{
m <- c(rev(cummax(rev(s[-1]))), 1)
ub <- which(s <= m)[1]
s[seq_len(ub - 1)] <- 1