Skip to content

Instantly share code, notes, and snippets.

@kenpenn
kenpenn / .block
Last active June 4, 2018 04:57
D3 Gangnam Style! v4
license: gpl-3.0
height: 600
@jonocarroll
jonocarroll / images_as_xaxis_labels_updated.R
Last active September 7, 2021 05:43
Implements @baptiste's much better method for making this work
library(ggplot2) ## devtools::install_github("hadley/ggplot2)
library(grid) ## rasterGrob
library(EBImage) ## readImage (alternatively: magick::image_read)
library(ggthemes) ## theme_minimal
## ##########
## INDEPENDENT CODE TO BE SOURCED:
## ##########
# user-level interface to the element grob
@jonocarroll
jonocarroll / add_images_as_xlabels.R
Created June 2, 2016 12:10
Replace categorical x-axis labels with images
#' Replace categorical x-axis labels with images
#'
#' Pipe a ggplot2 graph (with categorical x-axis) into this function with the argument of a list of
#' pictures (e.g. loaded via readImage) and it builds a new grob with the x-axis categories
#' now labelled by the images. Solves a problem that you perhaps shouldn't have.
#'
#' @author J. Carroll, \email{jono@@jcarroll.com.au}
#' @references \url{http://stackoverflow.com/questions/29939447/icons-as-x-axis-labels-in-r-ggplot2}
#'
#' @param g ggplot graph with categorical x axis
@hrbrmstr
hrbrmstr / aplot.png
Last active March 27, 2016 03:37
Nuclear Explosions
aplot.png
@richarddmorey
richarddmorey / likert_check.R
Last active March 4, 2017 14:51
R script to check possible means and standard deviations for likert responses
############
# Option 1: Get all solutions
# using brute force
############
## This function creates every possible distribution of responses for
## a likert scale with nlev responses. This is total brute force. There's
## probably a better way.
## Argument:
## v : initially, the total number of responses
@roblanf
roblanf / genome_plots.r
Last active September 4, 2016 09:23
Make plots about genome sequencing, size, and gene content
source("http://bioconductor.org/biocLite.R")
biocLite("genomes")
library(genomes)
library(ggplot2)
valid <- c("released", "created", "submitted")
data(proks)
update(proks)
@sdjacobs
sdjacobs / cities.tsv
Last active March 2, 2019 02:14
Dijkstra's algorithm in Javascript/D3
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 29 columns, instead of 13. in line 6.
Cities1 Birmingham Boston Buffalo Chicago Cleveland Dallas Denver Detroit El Paso Houston Indianapolis Kansas City Los Angeles Louisville Memphis Miami Minneapolis New Orleans New York Omaha Philadelphia Phoenix Pittsburgh St. Louis Salt Lake City San Francisco Seattle Washington
Birmingham, Ala. — 1194 947 657 734 653 1318 754 1278 692 492 703 2078 378 249 777 1067 347 983 907 894 1680 792 508 1805 2385 2612 751
Boston, Mass. 1194 — 457 983 639 1815 1991 702 2358 1886 940 1427 3036 996 1345 1539 1402 1541 213 1458 304 2664 597 1179 2425 3179 3043 440
Buffalo, N.Y. 947 457 — 536 192 1387 1561 252 1928 1532 510 997 2606 571 965 1445 955 1294 436 1011 383 2234 219 749 1978 2732 2596 386
Chicago, Ill. 657 983 536 — 344 931 1050 279 1439 1092 189 503 2112 305 546 1390 411 947 840 493 758 1729 457 293 1458 2212 2052 695
Cleveland, Ohio 734 639 192 344 — 1205 1369 175 1746 1358 318 815 2424 379 773 1325 763 1102 514 819 432 2052 131 567 1786 2540 2404 369
Dallas, Tex. 653 1815 1387 931 1205 — 801 1167 625 242 877 5

Dijkstra

A graph search algorithm that solves the single-source shortest path problem for a graph with non-negative edge path costs, producing a shortest path tree. This algorithm is often used in routing and as a subroutine in other graph algorithms.

Click to select source and destination.

@mbostock
mbostock / .block
Last active February 9, 2016 01:57
Animation Benchmark
license: gpl-3.0
@skranz
skranz / s_dplyr
Created March 21, 2014 07:48
Wrappers to dplyr's data modification functions like arrange, select,... that work with string arguments.
# Helper functions that allow string arguments for dplyr's data modification functions like arrange, select etc.
# Author: Sebastian Kranz
# Examples are below
#' Modified version of dplyr's filter that uses string arguments
#' @export
s_filter = function(.data, ...) {
eval.string.dplyr(.data,"filter", ...)
}