Skip to content

Instantly share code, notes, and snippets.

View timelyportfolio's full-sized avatar

timelyportfolio timelyportfolio

View GitHub Profile
@timelyportfolio
timelyportfolio / axys-r-d3-websockets.r
Created July 19, 2012 17:34
axys to excel to d3 to r and back
#borrowed significant and substantial portions of code from http://bigcomputing.com/PerformanceAnalytics.R
#see youtube http://www.youtube.com/embed/0iR8Fo0jwW8 for the demo
# R/websockets example
if(any(is.na(packageDescription('caTools'))))
stop("This demo requires the caTools package.\nRun install.packages('caTools') to install it.\n\n")
if(any(is.na(packageDescription('PerformanceAnalytics'))))
stop("This demo requires the PerformanceAnalytics package.\nRun install.packages('PerformanceAnalytics') to install it.\n\n")
library('websockets')
library('caTools')
@timelyportfolio
timelyportfolio / index.html
Created July 23, 2012 19:13
groups axis error fix
<!doctype html>
<html>
<head></head>
<body>
<script src="http://d3js.org/d3.v2.min.js?2.9.1"></script>
<script>
var margin = {top: 20, right: 15, bottom: 60, left: 60};
var width = 700 - margin.left - margin.right;
var height = 500 - margin.top - margin.bottom;
@timelyportfolio
timelyportfolio / index.html
Created July 23, 2012 19:28
performance charts example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>d3.js Axys Performance Chart</title>
<script src="http://d3js.org/d3.v2.min.js?2.9.1"></script>
<style>
.axis path, .axis line {
fill: none;
stroke: #000;
@timelyportfolio
timelyportfolio / spainallocation.r
Created July 24, 2012 18:28
spain stocks and bonds
#analyze asset allocation experience in Spain
require(lattice)
require(latticeExtra)
require(reshape2)
require(directlabels)
require(quantmod)
require(PerformanceAnalytics)
require(RQuantLib)
@timelyportfolio
timelyportfolio / index.html
Created July 25, 2012 17:23
d3.js grouped bar with incorrect text rotation
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>d3.js Grouped Bar Chart</title>
<script src="http://d3js.org/d3.v2.min.js?2.9.1"></script> <style>
.axis path, .axis line {
fill: none;
stroke: #000;
@timelyportfolio
timelyportfolio / currencyplot.r
Created July 25, 2012 18:48
dendrogram grouped currency plot
require(quantmod)
require(fAssets)
#get asian currency data from the FED FRED data series
getSymbols("DEXKOUS",src="FRED") #load Korea
getSymbols("DEXMAUS",src="FRED") #load Malaysia
getSymbols("DEXSIUS",src="FRED") #load Singapore
getSymbols("DEXTAUS",src="FRED") #load Taiwan
getSymbols("DEXCHUS",src="FRED") #load China
getSymbols("DEXJPUS",src="FRED") #load Japan
@timelyportfolio
timelyportfolio / index.html
Created July 26, 2012 13:26
d3.js grouped bar chart with working rotation
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>d3.js Axys Chart</title>
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<script src="http://d3js.org/d3.v2.min.js?2.9.1"></script> <style>
@timelyportfolio
timelyportfolio / index.html
Created July 27, 2012 21:56
r websocket for interaction with d3
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>d3.js Axys Chart</title>
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<script src="http://d3js.org/d3.v2.min.js?2.9.1"></script> <style>
@timelyportfolio
timelyportfolio / horizon plot applied.r
Created July 31, 2012 17:15
horizon plot examples
require(lattice)
require(latticeExtra)
require(directlabels)
require(reshape2)
require(quantmod)
require(PerformanceAnalytics)
data(managers)
managers[which(is.na(managers),arr.ind=TRUE)[,1],
@timelyportfolio
timelyportfolio / README.md
Created August 1, 2012 15:37 — forked from mbostock/.block
Horizon Chart

Horizon charts combine position and color to reduce vertical space. Start with a standard area chart, then mirror negative values (in blue) or offset them vertically. Click the + button above to increase the number of bands, turning the area into a horizon.

Implemented with the d3.horizon plugin.