Skip to content

Instantly share code, notes, and snippets.

Avatar

Russell Dinnage rdinnager

View GitHub Profile
View this_code_makes_this_poster.R
## This code makes this poster
make_poster <- function() {
library(ggplot2);library(imager);library(dplyr)
library(tidyr); library(colorspace); library(
sysfonts); library(showtext); if( !file.exists(
"this_poster_is_made.png" ) ) { download.file(
"https://www.r-project.org/logo/Rlogo.png",
"Rlogo.png", mode = "wb"); font_add_google(
"Finger Paint");R_logo<-load.image("Rlogo.png")
;poster_text <-capture.output(print(make_poster
@rdinnager
rdinnager / @midnight_freq_players.csv
Last active Sep 14, 2015
Dynamic d3 barchart of @midnight contestants
View @midnight_freq_players.csv
player Gender hits first second third total simple.points image image_ht image_wd
Kumail Nanjiani M 404000 4 2 0 6 0.833333333333333 https://duckduckgo.com/i/b7d0c4ff.jpg 200 164
Andy Daly M 182000 2 3 1 6 0.583333333333333 https://duckduckgo.com/i/ff655da8.jpg 200 133
Kyle Kinane M 190000 7 1 2 10 0.75 https://duckduckgo.com/i/cb420bdf.jpg 200 300
Kristen Schaal F 512000 2 1 1 4 0.625 https://duckduckgo.com/i/0cf592c2.jpg 200 150
Patton Oswalt M 747000 1 2 0 3 0.666666666666667 https://duckduckgo.com/i/bbfa97b3.jpg 200 168
Matt Besser M 167000 3 3 1 7 0.642857142857143 https://duckduckgo.com/i/804ac973.jpg 200 100
Moshe Kasher M 107000 5 3 1 9 0.722222222222222 https://duckduckgo.com/i/122b4834.jpg 200 200
Jonah Ray M 160000 3 5 2 10 0.55 https://duckduckgo.com/i/09b947a3.jpg 200 310
Ron Funches M 154000 11 2 0 13 0.923076923076923 https://duckduckgo.com/i/d6db36c0.jpg 200 143
@rdinnager
rdinnager / @midnight_freq_players.csv
Created Sep 14, 2015
Testing out basic bar charts in D3 using @midnight data
View @midnight_freq_players.csv
Kumail Nanjiani M 404000 4 2 0 6 0.833333333333333 https://duckduckgo.com/i/b7d0c4ff.jpg 200 164
Andy Daly M 182000 2 3 1 6 0.583333333333333 https://duckduckgo.com/i/ff655da8.jpg 200 133
Kyle Kinane M 190000 7 1 2 10 0.75 https://duckduckgo.com/i/cb420bdf.jpg 200 300
Kristen Schaal F 512000 2 1 1 4 0.625 https://duckduckgo.com/i/0cf592c2.jpg 200 150
Patton Oswalt M 747000 1 2 0 3 0.666666666666667 https://duckduckgo.com/i/bbfa97b3.jpg 200 168
Matt Besser M 167000 3 3 1 7 0.642857142857143 https://duckduckgo.com/i/804ac973.jpg 200 100
Moshe Kasher M 107000 5 3 1 9 0.722222222222222 https://duckduckgo.com/i/122b4834.jpg 200 200
Jonah Ray M 160000 3 5 2 10 0.55 https://duckduckgo.com/i/09b947a3.jpg 200 310
Ron Funches M 154000 11 2 0 13 0.923076923076923 https://duckduckgo.com/i/d6db36c0.jpg 200 143
@rdinnager
rdinnager / @midnight_freq_players.csv
Created Sep 14, 2015
Testing SVG and CSV loading in D3
View @midnight_freq_players.csv
Kumail Nanjiani M 404000 4 2 0 6 0.833333333333333 https://duckduckgo.com/i/b7d0c4ff.jpg 200 164
Andy Daly M 182000 2 3 1 6 0.583333333333333 https://duckduckgo.com/i/ff655da8.jpg 200 133
Kyle Kinane M 190000 7 1 2 10 0.75 https://duckduckgo.com/i/cb420bdf.jpg 200 300
Kristen Schaal F 512000 2 1 1 4 0.625 https://duckduckgo.com/i/0cf592c2.jpg 200 150
Patton Oswalt M 747000 1 2 0 3 0.666666666666667 https://duckduckgo.com/i/bbfa97b3.jpg 200 168
Matt Besser M 167000 3 3 1 7 0.642857142857143 https://duckduckgo.com/i/804ac973.jpg 200 100
Moshe Kasher M 107000 5 3 1 9 0.722222222222222 https://duckduckgo.com/i/122b4834.jpg 200 200
Jonah Ray M 160000 3 5 2 10 0.55 https://duckduckgo.com/i/09b947a3.jpg 200 310
Ron Funches M 154000 11 2 0 13 0.923076923076923 https://duckduckgo.com/i/d6db36c0.jpg 200 143
@rdinnager
rdinnager / @midnight_freq_players.csv
Created Sep 12, 2015
Data on number of wins for comedians who frequently appear on @midnight panel show
View @midnight_freq_players.csv
player Gender hits first second third total simple.points image image_ht image_wd
Kumail Nanjiani M 404000 4 2 0 6 0.833333333333333 https://duckduckgo.com/i/b7d0c4ff.jpg 200 164
Andy Daly M 182000 2 3 1 6 0.583333333333333 https://duckduckgo.com/i/ff655da8.jpg 200 133
Kyle Kinane M 190000 7 1 2 10 0.75 https://duckduckgo.com/i/cb420bdf.jpg 200 300
Kristen Schaal F 512000 2 1 1 4 0.625 https://duckduckgo.com/i/0cf592c2.jpg 200 150
Patton Oswalt M 747000 1 2 0 3 0.666666666666667 https://duckduckgo.com/i/bbfa97b3.jpg 200 168
Matt Besser M 167000 3 3 1 7 0.642857142857143 https://duckduckgo.com/i/804ac973.jpg 200 100
Moshe Kasher M 107000 5 3 1 9 0.722222222222222 https://duckduckgo.com/i/122b4834.jpg 200 200
Jonah Ray M 160000 3 5 2 10 0.55 https://duckduckgo.com/i/09b947a3.jpg 200 310
Ron Funches M 154000 11 2 0 13 0.923076923076923 https://duckduckgo.com/i/d6db36c0.jpg 200 143
@rdinnager
rdinnager / ALF.R
Created Jul 22, 2014
Code to run simple ALF simulation from R
View ALF.R
## Generate ALF simulations
library(whisker)
ALF_template <- function() {
" webRequest := false;
uuid := '4e4937bd-70e5-4caf-8521-f4340a4b7e09';
# name of simulation - you may want to change this
mname := {{{simname}}};
# directories for file storage - you may want to change these
View ListToDf.md

Is there an easy way to convert a named list into a dataframe, preserving the elements of the list in a "list-column"?

library(dplyr)
library(magrittr)

## make a random matrix
rand_mat <- function() {
  Nrow <- sample(2:15,1)
  Ncol <- sample(2:15,1)
@rdinnager
rdinnager / gist:da324a55c6c5bb7703fd
Last active Aug 29, 2015
Function to select colours from a palette by maximizing Mean Perceptual Distance (MPD)
View gist:da324a55c6c5bb7703fd
require(picante)
require(colorspace)
#' Select colours from a palette to maximize perceptual distance between the colours
#'
#' This function takes a palette as a character vector of hexidecimal colours, and returns a smaller palette,
#' attempting to maximize the mean perceptual distance (MPD) between the colours in the new palette. It uses CIELAB
#' colorspace to map colour to a perceptually meaningful scale before maximizing distances
#'
#' @param pal A palette as a character vector containing hexidecimal coded colours
#' @param sat.thresh Minimum saturation of colours in resulting palette (between 0 and 1)
@rdinnager
rdinnager / magrittr_challenge.md
Last active Aug 29, 2015
magrittr Challenge accepted!
View magrittr_challenge.md

magrittr Challenge!

A picture suitable for a fancy pipe enthusiast

My good friend Andrew recently posted this gist, purporting