Skip to content

Instantly share code, notes, and snippets.

View DataStrategist's full-sized avatar

Amit Kohli DataStrategist

View GitHub Profile
library(plyr)
library(ggplot2)
s <- read.csv("<filename.csv>", sep=",", row.names=NULL)
colnames(s) <- c("date", "type", "desc", "value", "balance", "acc")
s$date <- as.Date(s$date, format="%d/%m/%Y")
s <- s[,1:5]
s$month <- as.Date(cut(s$date, breaks="month"))
s <- subset(s, s$value < 0)
' Excel macro to export all VBA source code in this project to text files for proper source control versioning
' Requires enabling the Excel setting in Options/Trust Center/Trust Center Settings/Macro Settings/Trust access to the VBA project object model
' modified to ask what workbook to export stuff from instead of doing it automatically for Activeworkbook.
Public Sub ExportVisualBasicCode()
Const Module = 1
Const ClassModule = 2
Const Form = 3
Const Document = 100
Const Padding = 24
SankeyR <- function(inputs, losses, unit, labels, format="plot",
showPercent=TRUE, maxScale=2.5, minFont=0.5,
titt=""){
########################
# SankeyR version 1.02 (updated June 3, 2015)
# is a function for creating Sankey Diagrams in R.
# See http://www.sankey-diagrams.com for excellent examples of Sankey Diagrams.
#
# OPTIONS:
# 'inputs' is a vector of input values