Skip to content

Instantly share code, notes, and snippets.

View timelyportfolio's full-sized avatar

timelyportfolio timelyportfolio

View GitHub Profile
example.md: example.Rmd
Rscript ./knit
example.ipynb: example.md
c://python27_64/scripts/notedown example.md | sed 's/%%r/%%R/' > example.ipynb
@timelyportfolio
timelyportfolio / code.R
Last active August 29, 2015 13:57 — forked from ramnathv/code.R
hair_eye_male = subset(as.data.frame(HairEyeColor), Sex == "Male")
n1 <- nPlot(Freq ~ Hair,
group = 'Eye',
data = hair_eye_male,
type = 'multiBarChart'
)
n1
@timelyportfolio
timelyportfolio / code.R
Last active August 29, 2015 13:58 — forked from ramnathv/code.R
library(rCharts)
p2 <- nPlot(mpg ~ wt, group = 'cyl', data = mtcars, type = 'scatterChart')
p2$xAxis(axisLabel = 'Weight')
p2$chart(size = '#! function(d){return d.gear} !#')
p2$chart(color = c('red', 'green', 'blue'))
p2$chart(
tooltipXContent = NA,
tooltipYContent = NA
)
p2$chart(
@timelyportfolio
timelyportfolio / anal.r
Last active August 29, 2015 14:02 — forked from michalskop/anal.r
#setwd('~/uhk/dev/ar_ondrej_plachy/institution/')
data = read.table('data.tsv',sep="\t",header=TRUE)
data$time = data$year - 1983
data$random1 = rnorm(336, mean=0, sd=0.01)
data$random2 = rnorm(336, mean=0, sd=0.01)
attach(data)
fbalm2 =
ifelse(balance_of_parties_mandates<= 0.25, '0.0-0.25',
ifelse(balance_of_parties_mandates <= 0.5, '0.25-0.5',

This example pulls together various examples of work with trees in D3.js.

The panning functionality can certainly be improved in my opinion and I would be thrilled to see better solutions contributed.

One can do all manner of housekeeping or server related calls on the drop event to manage a remote tree dataset for example.

Dragging can be performed on any node other than root (flare). Dropping can be done on any node.

Panning can either be done by dragging an empty part of the SVG around or dragging a node towards an edge.

@timelyportfolio
timelyportfolio / README.md
Last active August 29, 2015 14:08 — forked from mbostock/.block
Yield Curve Animation with a d3.js brush as slider

Forked from Mike Bostock's brush as slider example, I use the brush/slider to drive an interactive exploration of the US Yield Curve. I think this is a much more helpful way of showing the data than the animated GIF from Treasury yield curve from the Volcker era through Greenspan, Bernanke, and Yellen.

Original Readme.md

By customizing the display of D3'��s [brush component](https://github.com/mbostock/d3/wiki/SVG-Controls), you can make a single-handle slider. Or, by using [custom resize handles](/mbostock/4349545), you can make a two-handled slider.
#Run hclust
hc <- hclust(dist(USArrests[1:40,]), "ave")
#Function for extracting nodes and links
extractGraph<-function(hc){
n<-length(hc$order)
m<-hc$merge
links<-data.frame(source=as.numeric(), target=as.numeric(), value=as.numeric())
/**
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="http://d3js.org/d3.v3.min.js"></script>
<style>
body {
font: 10px sans-serif;
}
#main {