Skip to content

Instantly share code, notes, and snippets.

View patternproject's full-sized avatar

patternproject

View GitHub Profile
@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
@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")
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)
@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,
@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++;
}
@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")
@jennybc
jennybc / polygraphing-films.R
Created April 9, 2016 16:46
Get polygraphing's film data into R
## http://polygraph.cool/films/
## https://github.com/matthewfdaniels/scripts
x <- "https://raw.githubusercontent.com/matthewfdaniels/scripts/master/data/character_list5.csv"
characters <- read.csv(x, na.strings = c("NULL", "?"),
fileEncoding = "ISO-8859-1", stringsAsFactors = FALSE)
## some ages are clearly (negative) birth years ... oops
characters$age[!is.na(characters$age) & characters$age < 0] <- NA
characters$age[!is.na(characters$age) & characters$age > 105] <- NA

You'll need to make 2 plots and use grid.arrange if you want more uniform spacing in 8.1 and 8.2. You can add a fill to strip.background to extend the background colors and rotate the text with strip.text

@timelyportfolio
timelyportfolio / Readme.md
Last active June 22, 2024 16:32
3d yield curve with Plotly in R

Nowhere near as spectacular as the Upshot/New York Times 3d yield curve by Amanda Cox and Gregor Aisch, but not bad at all for a couple of lines of R code with the plotly htmlwidget.

library(plotly)
library(dplyr)
library(tidyr)
library(purrr)
library(quantmod)
library(magrittr)
library(rvest)
library(urltools)
library(rmarkdown)
# Some Rmd template setup -----------------------------------------------------------
preamble <- '---
title: "CRAN Mirrors Certificate Expiration Dashboard (Days left from %s)"
output:
flexdashboard::flex_dashboard: