This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' 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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(googleVis) | |
## Set wd | |
setwd("your folder") | |
df <- data.frame(thing=c("A","B","C","D"), | |
measure=c(12,3,4.5,17)) | |
## unimpresive dashboard | |
plot(gvisTable(df)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## This function takes inputs and converts them from a data.frame like FROM TO VALUE into two dataframes: | |
## Nodes and Edges. This is suitable for the packages VisNetwork and network3d. | |
## output will be a list containing both dataframes | |
## The indexing is important. By default, the edges will be 1-indexed (for VisNetwork), but if you're using it with | |
## network3d, change the indexing to 0 | |
easyMode <- function(df,Index=1){ | |
nodes <- data.frame(name=df[,1:2] %>% unlist %>% as.character() %>% unique()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |