Skip to content

Instantly share code, notes, and snippets.


Ramnath Vaidyanathan ramnathv

View GitHub Profile
ramnathv / orig.png
Created Mar 23, 2016 — forked from hrbrmstr/orig.png
Supreme Annotations - moar splainin here: - NOTE: this requires the github version of ggplot2
ramnathv / ab_test.R
Last active Feb 6, 2018
A/B Testing
View ab_test.R
# fix required for R versions earlier than 3.1.2
if (R.Version()$minor < "1.2") {
## Hypothesis Testing and A/B Tests
n <- 10^4
p1 <- 0.05
p2 <- p1 + 0.005
alpha <- 0.05
sd <- sqrt(p1*(1 - p1)/n)

React <-> D3 Resources

This is a incomplete list of resources on how to link react & d3. To my experience, there are as many approaches as there are (enter something numerous here). These approaches mostly differ as to 'who' has control over the dom and does the transitions etc. That distinction either requires the user to know more about react or d3, vice versa. Some of the approaches (like react-d3 or react-d3-components) include prebuilt charts, other just provide frameworks to place your charts in.

The following list tries to summarize some of the approaches, hopefully there will be some convergence to a (set of) standard(s), at one point.

This list is UNSORTED.

ramnathv /
Created Feb 2, 2016
Plotly Hover Events in Shiny

This is a demo of how to get plotly events back to shiny server.

Let us start by loading required libraries and preparing data. We use the ubiquitous mtcars dataset.

# Load Libraries ----
ramnathv /
Last active Feb 11, 2016
Import D3 Block in RStudio

Livecoding D3 in RStudio

This is a proof-of-concept on how one can use RStudio to livecode D3 visualizations.


You will need to install a couple of packages before getting started

ramnathv /
Created Jan 28, 2016 — forked from mbostock/.block
Inline Labels

This example shows how to implement Ann K. Emery’s technique of placings labels directly on top of a line in D3 4.0 Alpha.

To construct the multi-series line chart, the data is first transformed into separate arrays for each series. (The series names are automatically derived from the columns in the TSV file, thanks to a new dsv.parse feature.)

var series = data.columns.slice(1).map(function(key) {
  return {
    return {
      key: key,
ramnathv /
Created Jan 28, 2016 — forked from kerryrodden/.block
Sequences sunburst

This example shows how it is possible to use a D3 sunburst visualization (partition layout) with data that describes sequences of events.

A good use case is to summarize navigation paths through a web site, as in the sample synthetic data file (visit_sequences.csv). The visualization makes it easy to understand visits that start directly on a product page (e.g. after landing there from a search engine), compared to visits where users arrive on the site's home page and navigate from there. Where a funnel lets you understand a single pre-selected path, this allows you to see all possible paths.


  • works with data that is in a CSV format (you don't need to pre-generate a hierarchical JSON file, unless your data file is very large)
  • interactive breadcrumb trail helps to emphasize the sequence, so that it is easy for a first-time user to understand what they are seeing
  • percentages are shown explicitly, to help overcome the distortion of the data that occurs wh
View crosstalk_demo.R
# Source:
app <- tagList(
d3scatter(mtcars, ~wt, ~mpg, ~cyl, group = "A", height = 200, width = 400),
parcoords(mtcars, brushMode = "1d", crosstalk_group = "A", height = 300, width = 500)
You can’t perform that action at this time.