Skip to content

Instantly share code, notes, and snippets.

View patternproject's full-sized avatar

patternproject

View GitHub Profile
@mrecos
mrecos / Boxplot_compare.R
Last active May 6, 2023 19:28
Code for blog post: http://matthewdharris.com/2016/03/29/boxplot-or-not-to-boxplot-woe-ful-example/ A post to compare a bunch of visualizations against the boxplot.
library("data.table")
library("rowr")
library("dplyr")
library("ggplot2")
library("Information")
library("knitr")
library("ggrepel")
library("ggthemes")
library("ggalt")
library("xtable")
@cmtoomey
cmtoomey / Animate.js
Created March 28, 2016 20:05
Tableau Animation
i = 1
function interval() {
var i = 0;
setInterval(function() {
if (i < 70) {
console.log("The count is: " + i);
animate1(i);
i++;
}
@ottlngr
ottlngr / keystrokes.R
Last active April 5, 2016 05:36
Visualizing keystrokes using ggplot2
##### Visualizing keystrokes using ggplot2 #####
library(ggplot2)
# a character string to visualize:
string <- 'R is an integrated suite of software facilities for data manipulation, calculation and graphical display.'
# a data.frame representing the keys of a qwerty keyboard
qwerty <- data.frame(
id = 1:53,
library("ggplot2") # Must use Dev version as of 03/18/16
library("gridExtra")
library("extrafont") # for font selection
library("dplyr") # for data preperation
library("cowplot") # for combining plots
# Prepare data for plotting
# data from Zubrow, E.B.W. (1974), Population, Contact,and Climate in the New Mexican Pueblos
# prepared as a long format to facilitate plotting
year <- c(1760, 1790, 1797, 1850, 1860, 1889, 1900, 1910, 1950)
@mrecos
mrecos / Zubrow Pop Change ggplot2.r
Created March 16, 2016 10:09
Used Zubrow (1974) data on population change over time in Pueblos of New Mexico to illustrate new features in ggplot2: subtitles and caption. More details on these new features can be found here: https://gist.github.com/hrbrmstr/283850725519e502e70c
library("ggplot2") # Must be dev version, use: devtools::install_github("hadley/ggplot2")
library("gridExtra")
library("extrafont") # Need to follow steps here: http://zevross.com/blog/2014/07/30/tired-of-using-helvetica-in-your-r-graphics-heres-how-to-use-the-fonts-you-like-2/
# create data frame
year <- c(1760, 1790, 1797, 1850, 1860, 1889, 1900, 1910, 1950)
sites <- c("Isleta", "Acoma", "Laguna", "Zuni", "Sandia", "San Felipe",
"Santa Ana", "Zia", "Santo Domingo", "Jemez", "Cochiti",
"Tesuque", "Nambe", "San Ildefonso", "Pojoaque", "Santa Clara",
"San Juan", "Picuris", "Toas")
@hrbrmstr
hrbrmstr / orig.png
Last active July 16, 2023 06:43
Supreme Annotations - moar splainin here: http://rud.is/b/2016/03/16/supreme-annotations/ - NOTE: this requires the github version of ggplot2
orig.png
@timelyportfolio
timelyportfolio / README.md
Last active December 9, 2017 18:45
nesting and summarizing in R and d3.js

Built with blockbuilder.org

Nesting and summarizing data is a very common task for data analysis. I thought it would be nice to view parallel ways of nesting and summarizing with both

  • R | tidyr and dplyr
  • JavaScript | d3.js ...v4 for fun

To avoid context switching, I'll take advantage of the R package V8. If you are an R user, then these d3.js gists might be helpful d3 nest examples and Mister Nester.

@hrbrmstr
hrbrmstr / badmail.Rmd
Last active December 1, 2016 07:59
Code for this post:
---
title: "Visualizing the Clinton Email Network in R"
author: "hrbrmstr"
date: "`r Sys.Date()`"
output: html_document
---
```{r include=FALSE}
knitr::opts_chunk$set(
collapse=TRUE,
comment="#>",
@mrecos
mrecos / DF string split and concatenate.r
Created February 8, 2016 21:53
Two R functions; 1) recode values in a vector based on a look up table including replacement for NA and no matching codes; 2) take a vector of concatenated codes, split based on a character, recode, and concatenate back together.
lut_match <- function(LUT, code_field, desc_col = 2, is_NA = "NA", no_code = "N/A"){
require(stringr)
require(splitstackshape)
# this loops through all unique codes in code_field. Potentially slow
code_field[which(code_field == "")] <- NA
unique_code <- unique(code_field)
coded <- code_field
for(i in seq_along(unique_code)){
if(is.na(unique_code[i])){
coded[is.na(coded)] <- is_NA # set this to whatever works
@johnburnmurdoch
johnburnmurdoch / data_.csv
Last active March 9, 2016 04:44
Share of minutes played broken down by nationality, across Premier League seasons
seasonStart group total share barTops barBases
1 1992 Other EU 22536 0.024715160408366 0.024715160408366 0
2 1992 non-EU 41531 0.0455469172399649 0.070262077648331 0.024715160408366
3 1992 Ireland 63597 0.0697466301247273 0.140008707773058 0.070262077648331
4 1992 Rest of UK 146838 0.16103677334237 0.301045481115428 0.140008707773058
5 1992 England 637327 0.698954518884572 1 0.301045481115428
6 1993 Other EU 27526 0.0301765248869175 0.0301765248869175 0
7 1993 non-EU 62492 0.0685094599009391 0.0986859847878566 0.0301765248869175
8 1993 Ireland 54388 0.0596251120958247 0.158311096883681 0.0986859847878566
9 1993 Rest of UK 124047 0.135991694494204 0.294302791377885 0.158311096883681