Skip to content

Instantly share code, notes, and snippets.

@austinschwartz
Last active September 18, 2017 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save austinschwartz/c78d899959a89ab404128bca05375bca to your computer and use it in GitHub Desktop.
Save austinschwartz/c78d899959a89ab404128bca05375bca to your computer and use it in GitHub Desktop.
library(scales)
library(ggplot2)
library(ggthemes)
library("devtools")
library("slopegraph")
CSV_Text = '"","jaro","dice","levNorm"
"a shot",0.8888888888888888,1,0.6666666666666667
"keanu (reeves)",0.8714285714285714,0.5333333333333333,0.3571428571428571
"the woodwork",0.8425925925925926,0.8,0.5833333333333333
"oranges and apples",0.6527777777777778,1,0.4444444444444444
"dan aykroyd & eddie murphy",0.6042124542124542,0.8333333333333334,0.2142857142857143
"baby tooth",0.92,0.5714285714285714,0.8
"mammon (money later accepted)",0.7517241379310344,0.3076923076923077,0.1724137931034483
"bonsai",0.9611111111111111,0.4,0.6666666666666667
"salvador dali",0.4935897435897436,0.46153846153846156,0.3076923076923077
"peer to peer",0.6875,0.4117647058823529,0.3125
"cocoa puffs",0.6966810966810967,0.11764705882352941,0.25
"u.s.a.",0.4365079365079365,0,0'
nat = read.csv(text=CSV_Text, header=TRUE)
nat <- cbind(nat[1],sapply(nat[-1],function(x) x*100))
rownames(nat) <- (nat[,1])
nat <- nat[,-1]
rlabs = nat[ncol(nat)]
row.names(rlabs) <- c("shot","keanu","wood work","apples and oranges","eddie murphy and dan ackroyd","baby teeth","money","bonasi","dali","p2p (peer-to-peer communication)","cookie crisp","america")
cols <- rainbow(nrow(nat))
ggslopegraph(nat, offset.x = 0.05, yrev = FALSE, rightlabels = rlabs, na.span=TRUE,
col.lines = cols, col.num = cols, decimals = 0) +
theme_tufte(base_size = 15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment