Skip to content

Instantly share code, notes, and snippets.

View jalapic's full-sized avatar

James Curley jalapic

View GitHub Profile
@yannabraham
yannabraham / beanplots.R
Created July 16, 2012 09:31
ggplot2 BeanPlots
## reproduce the figures from http://www.jstatsoft.org/v28/c01/paper using ggplot2
library(ggplot2)
## parameters
set.seed(2710)
## Figure 1
d <- rnorm(50)
@nowherenearithaca
nowherenearithaca / README.md
Last active April 11, 2016 04:22
Making a Heat Map Legend with D3 - a Simple Example

This is an example of creating what could be a legend for a heat map, demonstrating the simple use of a data-driven linear gradient with D3.

@bhoung
bhoung / trueskill_ex2.r
Last active September 30, 2021 02:51
Example 2. Running trueskill algorithm on a tennis tournament.
# This second example runs Trueskill on a tennis tournament, the Australian Open.
# Note that actual computation is commented out as it takes about ~40 seconds to
# update skill ratings over 127 matches.
library(trueskill)
# Data format of ausopen2012 is: Player, Opponent, Margin, Round, WRank, LRank
data("ausopen2012")
# create match_id in order to reshape
@abresler
abresler / tufte
Last active July 4, 2023 18:56
Recreating Edward Tufte's New York City Weather Visualization
library(dplyr)
library(tidyr)
library(magrittr)
library(ggplot2)
"http://academic.udayton.edu/kissock/http/Weather/gsod95-current/NYNEWYOR.txt" %>%
read.table() %>% data.frame %>% tbl_df -> data
names(data) <- c("month", "day", "year", "temp")
data %>%
group_by(year, month) %>%
@abresler
abresler / gist:6911f5eb5d3834fc6d55
Last active August 29, 2015 14:15
gotham_cookies_graphviz
library(rvest)
library(htmltools)
library(pipeR)
library("DiagrammeR")
html('
<ul class="ze_imagelist" style="width:925px;height:400px;" id="slideshowpj_widget_54da647bbdf7e"><li class="ze_thumb ze_type_image ze_item_number_1"><a class="ze_box" rel="prettyPhoto[pj_widget_54da647bbdf7e]" href="http://ec12.cdn.cincopa.com/SaltedCaramel2.jpg?o=1&amp;res=76&amp;cdn=ec&amp;p=y&amp;pid=231720&amp;ph3=b2d1timslim1sat2p2lxtiganpc1chim&amp;d=AMWAjFwULOAANQJsAMnyJRB&amp;as=mp3" title="Salted Caramel - Our Signature Cookie<br />Our Signature Cookie! Caramel-infused dough loaded with Chocolate Chips and drizzled with Salted Caramel Sauce" style="width:190px;height:190px;"> <div class="ze_overlay"></div> <div id="pj_widget_54da647bbdf7e_0_thumbsplash" class="ze_item" style="width:190px;height:190px;"> <img class="ze_postar" style="height:190px;" src="http://ec12.cdn.cincopa.com/SaltedCaramel2.jpg?o=1&amp;res=76&amp;cdn=ec&amp;p=y&amp;pid=231720&amp;ph3=b2d1timslim1sat2p2lxtiganpc1chim&amp;d=AMWAjFwULOAANQJsAMnyJRB" t
@1wheel
1wheel / index.html
Last active October 31, 2016 17:58
Stacked Bump Chart
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body{
margin: 0px;
font: 10px sans-serif;
}
path.player{
@hrbrmstr
hrbrmstr / viridis_scales.R
Created July 19, 2015 18:45
viridis color/fill scales for ggplot2
viridis_pal <- function(alpha=1) {
function(n) {
viridis(n, alpha)
}
}
scale_color_viridis <- function(..., alpha=1, discrete=TRUE) {
if (discrete) {
discrete_scale("colour", "viridis", viridis_pal(alpha), ...)
@abresler
abresler / plot_player_shot_chart.r
Last active April 24, 2018 18:52
R function to auto generate heat map shot charts, need help completing court drawing then to complete
#' NBA Player Shot Chart
#'
#' @param player name the player, must be exact
#' @param author, year_end_season: numeric end of season
#'
#' @return
#' @export
#'
#' @examples boggie_bog <- plot_player_shot_chart(player = "Bojan Bogdanovic",
#year_season_end = 2015, exclude_backcourt = T
@timelyportfolio
timelyportfolio / Readme.md
Last active August 29, 2015 14:28 — forked from jalapic/gana.csv
Heatmap of touches (in rbokeh)

@jalapic did these really nice set of touch heatmap charts. On Twitter, there was a discussion how to do this interactively with d3.js or some other JavaScript. I definitely have some ideas how to accomplish this, but for now let's see how we can kind of do it in rbokeh. There is just a small issue with palette selection in Bokeh that does not let us allow a no color that prevents us from getting really close.

## https://gist.github.com/jalapic/3616c0197ece24060e99
library(rbokeh)
library(dplyr)

gana <- read.csv("https://gist.githubusercontent.com/jalapic/3616c0197ece24060e99/raw/2bc2361c5fceb9be80dece9b7ffa14d129a3edfb/gana.csv")

figure() %>%
@slowkow
slowkow / plot_repel.R
Last active May 2, 2018 21:07
Repel text labels away from each other in a ggplot2 figure.
library(ggplot2)
library(FField)
# You'll have to play with repulsion, cex.x, and cex.y to get satisfactory results.
plot_text <- function(x, y, label, repulsion = 1, cex.x = 110, cex.y = 40) {
dat <- data.frame(xpos = x, ypos = y, label = label)
dat$label <- as.character(dat$label)
# Use the FField package to repel the text labels away from each other.
dat <- cbind(