Skip to content

Instantly share code, notes, and snippets.

@epijim
Created February 5, 2014 22:51
Show Gist options
  • Save epijim/8834992 to your computer and use it in GitHub Desktop.
Save epijim/8834992 to your computer and use it in GitHub Desktop.
setwd("~/Dropbox/Personal/fun with code/sankey_arrow")
sourc.https <- function(url, ...) {
# install and load the RCurl package
if (match('RCurl', nomatch=0, installed.packages()[,1])==0) {
install.packages(c("RCurl"), dependencies = TRUE)
require(RCurl)
} else require(RCurl)
# parse and evaluate each .R script
sapply(c(url, ...), function(u) {
eval(parse(text = getURL(u, followlocation = TRUE,
cainfo = system.file("CurlSSL", "cacert.pem",
package = "RCurl"))), envir = .GlobalEnv)
} )
}
# from https://gist.github.com/1423501
sourc.https("https://gist.github.com/epijim/8832627/raw/91f8fb601a483a6e60c6cbc7eeea939e010cf7ce/Sankey.R")
inputs = c(35297)
losses = c(1758,8885,23787,867)
unit = "n ="
labels = c("At high diabetes risk",
"Did not meet criteria",
"Did not attend screening",
"Did not have diabetes",
"Diagnosed with diabetes")
pdf("Sankey.pdf", width=12, height=10)
SankeyR(inputs,losses,unit,labels)
dev.off()
# Clean up my mess
rm("inputs", "labels", "losses", "SankeyR", "sourc.https", "unit")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment