Skip to content

Instantly share code, notes, and snippets.

@jfreels
jfreels / test
Created March 8, 2013 03:51
this is a test
test
var vis = d3.select("#visualisation");
function update () {
var circles = vis.selectAll("circle").data(randomData(), function (d) { return d.id; });
circles.enter()
.insert("svg:circle")
.attr("cx", function (d) { return d.value1; })
.attr("cy", function (d) { return d.value2; })
.style("fill", "red");
@jfreels
jfreels / htmlTemplate.html
Last active December 14, 2015 21:39
html template
<!DOCTYPE html>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
</head>
<body>
<h1>This is a test</h1>
<script>
d3.select("body").append("p").html("Hello World!");
</script>
@jfreels
jfreels / jf.table.drought()
Last active December 17, 2015 14:18
Drought table example
### Drought
### A drought is a flat period in performance.
### The max drought is the longest flat period in a track record.
### The current drought is the current flat period in a track record.
require(devtools)
install_github("r_jfreels","jfreels")
# load data
require(PerformanceAnalytics)
<!doctype HTML>
<html>
<head>
<link rel='stylesheet' href='http://cdn.strategiqcommerce.com/ajax/libs/rickshaw/1.2.1/rickshaw.min.css'>
<link rel='stylesheet' href='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css'>
<script src='http://d3js.org/d3.v2.min.js' type='text/javascript'></script>
<script src='http://cdn.strategiqcommerce.com/ajax/libs/rickshaw/1.2.1/rickshaw.min.js' type='text/javascript'></script>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js' type='text/javascript'></script>
<script src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.min.js' type='text/javascript'></script>
<!doctype HTML>
<html>
<head>
<link rel='stylesheet' href='http://cdn.strategiqcommerce.com/ajax/libs/rickshaw/1.2.1/rickshaw.min.css'>
<link rel='stylesheet' href='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css'>
<script src='http://d3js.org/d3.v2.min.js' type='text/javascript'></script>
<script src='http://cdn.strategiqcommerce.com/ajax/libs/rickshaw/1.2.1/rickshaw.min.js' type='text/javascript'></script>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js' type='text/javascript'></script>
<script src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.min.js' type='text/javascript'></script>
@jfreels
jfreels / ddply_drawdown
Created August 28, 2013 21:23
Drawdown function for use with plyr / data.table
## Drawdown using plyr / data.table
vami<-function (ror) { cumprod(na.omit(ror) + 1) }
dd<-function (ror) { -(1 - vami(ror)/cummax(c(1, cummax(vami(ror))))[-1]) }
require(PerformanceAnalytics)
require(plyr)
require(reshape2)
require(data.table)
@jfreels
jfreels / knit_expand_edhec_histograms.Rmd
Last active March 27, 2017 10:04
knit_expand() example
knit_expand() example
========================================================
```{r, label='setup', include=FALSE}
require(data.table)
require(PerformanceAnalytics)
require(reshape2)
opts_chunk$set(eval=TRUE,echo=FALSE)
data(edhec)
edhec<-data.table(melt(data.frame(date=index(edhec),coredata(edhec)),id.vars='date'))
@jfreels
jfreels / edhec_long.json
Last active December 24, 2015 02:19
R to JSON: long vs. wide data.frame comparison
{
"date" : [
"1997-01-31",
"1997-02-28",
"1997-03-31",
"1997-04-30",
"1997-05-31",
"1997-01-31",
"1997-02-28",
"1997-03-31",
@jfreels
jfreels / README.md
Last active December 24, 2015 02:39
d3js: blank template

d3js: blank template