Skip to content

Instantly share code, notes, and snippets.

View wch's full-sized avatar

Winston Chang wch

View GitHub Profile
@wch
wch / vega-nan-transition.html
Created July 9, 2014 20:03
Vega transitions with NaN data
<!DOCTYPE html>
<html>
<head>
<script src="http://trifacta.github.io/vega/lib/d3.v3.min.js"></script>
<script src="http://trifacta.github.io/vega/vega.js"></script>
</head>
<body>
<script type="text/javascript">
var iris_spec = {
Version: 1.0
Type: Shiny
Title: Progress bar example
Author: RStudio, Inc.
AuthorUrl: http://www.rstudio.com/
License: MIT
Tags:
DisplayMode: Showcase
@wch
wch / code.R
Last active August 29, 2015 14:04
library(nycflights13)
library(dplyr)
library(ggvis)
library(lubridate)
# Summarize and join daily flight and weather data
daily <- flights %>%
filter(origin == "EWR") %>%
group_by(year, month, day) %>%
summarise(
@wch
wch / vega-gradient-base.html
Created August 28, 2014 19:42
Vega gradient with base URL
<!DOCTYPE html>
<html>
<head>
<base href="foo/">
<script src="http://trifacta.github.io/vega/lib/d3.v3.min.js"></script>
<script src="http://trifacta.github.io/vega/vega.js"></script>
</head>
<body>
<script type="text/javascript">
@wch
wch / escape_chars.R
Last active August 29, 2015 14:05
R function with C code for escaping characters
#' @useDynLib nameOfPackage C_escape_chars
deparse_vector3 <- function(x) {
.Call(C_escape_chars, x)
}
@wch
wch / as_json_numeric.R
Last active August 29, 2015 14:06
asJSON numeric collapsed
#' @export
#' @useDynLib rspeed C_as_json_numeric_collapsed
as_json_numeric_collapsed <- function(x, digits = 5,
round = c("signif", "decimal"),
na = c("string", "null")) {
round <- match.arg(round)
na <- match.arg(na)
.Call(C_as_json_numeric_collapsed, x, digits, round, na)
@wch
wch / app.R
Last active August 29, 2015 14:19
library(png)
library(ggplot2)
library(Cairo)
mtc <- mtcars
mtc$cyl <- factor(mtc$cyl)
mtc$am <- factor(mtc$am)
mtc$vs <- factor(mtc$vs)
@wch
wch / gist:1461760
Created December 11, 2011 17:47
Load and test branches from another person's repository
# ====== Do this once =======
# Add the remote git repository (this needs to be done once):
git remote add wch https://github.com/wch/ggplot2.git
git fetch wch
# Install devtools (this needs to be done once):
install.packages("devtools")
# ====== Do this each time you want to try the code =======
@wch
wch / badcontour-bisectlog.txt
Created January 31, 2012 19:22
git bisect log for ggplot2 contour coloring bug (#381)
git bisect start
# good: [a8b56fd752e9c5c186e1135c2700550560001cbc] New function to benchmark components of plotting
git bisect good a8b56fd752e9c5c186e1135c2700550560001cbc
# bad: [c5b872ed8b086965a17fc9953f25224ce84d0141] Don't test any example that takes over 5 seconds
git bisect bad c5b872ed8b086965a17fc9953f25224ce84d0141
# bad: [fe198da27c375723fb00f63f84724f3ef485dcb4] Message if grouping clearly incorrect in geom_path. Fixes #240
git bisect bad fe198da27c375723fb00f63f84724f3ef485dcb4
# bad: [fdb86c10228dd4bd8d71b8350d86fe5f08aa848b] Merge pull request #205 from davidmorrison/develop
git bisect bad fdb86c10228dd4bd8d71b8350d86fe5f08aa848b
# skip: [a783741bc1563b4a65f24dbcef4e49d34a5da08a] Added two examples to geom_text; non-variable annotation & font size change.