Skip to content

Instantly share code, notes, and snippets.

View abresler's full-sized avatar

Alex Bresler abresler

View GitHub Profile
@rich-iannone
rich-iannone / DiagrammeR_trigger_script.R
Last active September 20, 2023 06:22
DiagrammeR (https://github.com/rich-iannone/DiagrammeR)— Trigger a script from inside a graph series and modify that graph series. Uses the 'create_series' and 'trigger_script' functions.
# Install the latest version of DiagrammeR from GitHub
devtools::install_github("rich-iannone/DiagrammeR")
# Ensure that the package is loaded
library("DiagrammeR")
# So, here's a script that essentially takes an empty graph series, and
# creates a new graph on each new day it is triggered. It will create
# random nodes each time it's triggered and add those nodes to the graph
# belonging to the current day. Throughout the script, '_SELF_' refers
@hrbrmstr
hrbrmstr / us_states_hexgrid.geojson
Last active April 9, 2021 06:10
hexbin faceted choropleths in R
library(rgdal)
library(rgeos)
library(ggplot2)
library(readr)
library(tidyr)
library(dplyr)
library(grid)
us <- readOGR("us_states_hexgrid.geojson", "OGRGeoJSON")
@jebyrnes
jebyrnes / leafletMapWithLegend.R
Last active August 29, 2015 14:19
A demo of leaflet using a color legend
#devtools::install_github("rstudio/leaflet", ref="feature/color-legend")
library(leaflet)
library(RColorBrewer)
set.seed(100)
pdf <- data.frame(Latitude = runif(100, -90,90), Longitude = runif(100, -180,180))
#make a property with colors
pdf$Study <- rep(1:10,10)
#need to create a pal using colorbin
@noamross
noamross / base_r_plotting_tutorial_koontz_d-rug.r
Created April 24, 2015 17:34
Back to basics: High quality plots using base R graphics
### Title: Back to basics: High quality plots using base R graphics
### An interactive tutorial for the Davis R Users Group meeting on April 24, 2015
###
### Date created: 20150418
### Last updated: 20150423
###
### Author: Michael Koontz
### Email: mikoontz@gmail.com
### Twitter: @michaeljkoontz
###
(function(){
var margin = {
top: 20,
right: 40,
bottom: 50,
left: 40
},
width = 660 - margin.left - margin.right,
height = 340 - margin.top - margin.bottom;
@jalapic
jalapic / majorwinners
Created April 9, 2015 13:16
golf major winners
### Cumulative Golf Major Winners
library(XML)
masters <- readHTMLTable("http://en.wikipedia.org/wiki/Masters_Tournament")
masters <- masters[[4]][,1:2]
usopen <- readHTMLTable("http://en.wikipedia.org/wiki/U.S._Open_(golf)")
usopen <- usopen[[2]][,1:2]
@timelyportfolio
timelyportfolio / Readme.md
Last active August 29, 2015 14:17
TraMineR + rcdimple | Analyze State Sequence Data with dimple htmlwidget

As I read the TraMineR vignette, I thought this state sequence diagram would be an interesting use case for rcdimple. I'll throw in a little ggplot2, dplyr, tidyr, and pipeR for free.

See the live example.

library(rvest)
library(magrittr)
library(ggplot2)
library(dplyr)
library(tidyr)
library(scales)
# get page
pg <- html("http://www.bls.gov/opub/ted/2015/consumer-spending-by-age-group-in-2013.htm#tab-2")
@timelyportfolio
timelyportfolio / shinyApp.R
Last active August 29, 2015 14:17
forked from @rich-iannone dogs example
# Obtain 'dogs.csv'
# Created by Alex Bresler, available at:
# https://github.com/abresler/abresler.github.io/blob/master/blog/2015/february/exploring_agility_show/data/dogs.csv
dat_url <- "http://asbcllc.com/blog/2015/february/exploring_agility_show/data/dogs.csv"
dogs <- read.csv(dat_url, header = TRUE, stringsAsFactors = FALSE)
library(shiny)
# Install the latest DiagrammeR package from GitHub
# devtools::install_github("rich-iannone/DiagrammeR")
@hrbrmstr
hrbrmstr / sgmarkerex.R
Created March 13, 2015 01:36
state unemployment example for blog post
library(dplyr)
library(streamgraph)
library(pbapply)
# Grab some employment data from BLS --------------------------------------
url <- "http://www.bls.gov/lau/ststdsadata.txt"
dat <- readLines(url)
# Small function to grab data for a particular state ----------------------