Skip to content

Instantly share code, notes, and snippets.

@sdtaylor
sdtaylor / install_old_packages.R
Last active Apr 24, 2017
Install all the packages that were in the prior version of R
View install_old_packages.R
prior_version = 3.3
library_path = .libPaths()[1]
library_path = substr(library_path, 1, nchar(library_path)-3)
old_library_path=paste0(library_path, prior_version)
old_packages = list.files(old_library_path)
install.packages(old_packages)
@docsteveharris
docsteveharris / ggMMplot.R
Last active Feb 16, 2017
Mosaic plot using ggplot
View ggMMplot.R
#' @title Mosaic plot using ggplot.
#'
#' @description
#' Creates a mosaic plot where the dimensions of the cells of a
#' confusion matrix represent their marginal proportions.
#'
#' @details
#' Credit for initial iteration to
#' [Edwin](http://stackoverflow.com/a/19258045/992999)
#' This version adds color brewer options and tidies the labelling
@Thell
Thell / Exmple.Rmd
Created Jun 20, 2013
R markdown to illustrate creation of in-document referencing for chunks, sections, pages, and such.
View Exmple.Rmd
```{r setup, echo=FALSE, results='hide'}
chunkref <- local({
function(chunklabel) {
sprintf('[%s](#%s)', chunklabel, chunklabel )
}
})
secref <- local({
function(seclabel) {
sprintf('[%s](#%s)', seclabel, seclabel )
@aaronberdanier
aaronberdanier / Sankey.R
Created Dec 2, 2011
Program for creating sankey diagrams in R
View Sankey.R
SankeyR <- function(inputs, losses, unit, labels, format="plot"){
########################
# SankeyR version 1.01 (updated August 10, 2010)
# is a function for creating Sankey Diagrams in R.
# See http://www.sankey-diagrams.com for excellent examples of Sankey Diagrams.
#
# OPTIONS:
# 'inputs' is a vector of input values
# 'losses' is a vector of loss values
# 'unit' is a string of the unit
@hpiwowar
hpiwowar / bibtex_to_csv.py
Created Jul 1, 2011
For exporting bibtex info into csv for running stats
View bibtex_to_csv.py
#!/usr/bin/env python
# Initially written by Heather Piwowar, June 2011
# Public domain: have at it!
# For exporting bibtex info into csv for running stats
import csv
import re
from pybtex.database.input import bibtex as bibtex_in
from pybtex.database.output import bibtex as bibtex_out
from operator import itemgetter, attrgetter