Skip to content

Instantly share code, notes, and snippets.

View wch's full-sized avatar

Winston Chang wch

View GitHub Profile
@wch
wch / vega-newdata.html
Created February 21, 2014 01:31
Example of adding new data with duration in Vega
<!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 = {
@wch
wch / writetest.Rmd
Last active August 29, 2015 13:56
R string collection speed tests
String collection speed tests
========================================================
Source for this document at https://gist.github.com/wch/9233873
What's the fastest way to collect strings together in R and put them into a single output string? Probably the fastest way is to simply use `paste0('string1', 'string2')`, and so on -- but this assumes that you have all the strings collected and ready at one time. In many cases, this isn't possible, and you need to collect the strings together as you go.
This document contains benchmarks for different ways of collecting strings together. Some highlights:
* `textConnection` is super slow.
@wch
wch / check_results.txt
Created March 19, 2014 16:31
sessionInfo() from R CMD check on ShinyRGL package
==================================
R version 3.0.3 (2014-03-06)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
@wch
wch / DESCRIPTION
Last active August 29, 2015 13:57
Vertical layout example for R Shiny
Type: Shiny
Title: Vertical Layout
License: MIT
Author: Winston Chang <winston@rstudio.com>
AuthorUrl: http://www.rstudio.com/
Tags: vertical-layout
DisplayMode: Showcase
@wch
wch / DESCRIPTION
Last active August 29, 2015 13:57
submitButton demo app for R Shiny
Type: Shiny
Title: submitButton demo
License: MIT
Author: Winston Chang <winston@rstudio.com>
AuthorUrl: http://www.rstudio.com/
Tags: submitbutton
DisplayMode: Showcase
@wch
wch / DESCRIPTION
Created March 20, 2014 19:54
isolate demo for R Shiny
Type: Shiny
Title: isolate demo
License: MIT
Author: Winston Chang <winston@rstudio.com>
AuthorUrl: http://www.rstudio.com/
Tags: isolate
DisplayMode: Showcase
Type: Shiny
Title: Observer demo
License: MIT
Author: Winston Chang <winston@rstudio.com>
AuthorUrl: http://www.rstudio.com/
Tags: observer
DisplayMode: Showcase
@wch
wch / DESCRIPTION
Created March 24, 2014 16:33
navlistPanel example for R Shiny
Type: Shiny
Title: navlistPanel example
License: MIT
Author: Winston Chang <winston@rstudio.com>
AuthorUrl: http://www.rstudio.com/
Tags: navlistpanel
DisplayMode: Showcase
@wch
wch / Class6.R
Created May 9, 2014 15:29
Non-reference class in R with class methods
Class6 <- function(...) {
structure(list(...), class = "Class6")
}
# Methods for the class
Class6_methods <- list(
sum_xy = function(self) {
self$x + self$y
},
inc_x = function(self, amount = 1) {
@wch
wch / reactive_times.R
Last active August 29, 2015 14:02
Time tests for reactives
library(shiny)
# Reactives with no changes (after first)
v <- reactiveValues(x = 0)
r0 <- reactive(1) # 0 levels of dependence
r1 <- reactive(v$x) # 1 level
r2 <- reactive(r1()) # 2 levels
# Reactives with change
vc <- reactiveValues(x = 0)