Created
April 12, 2016 17:49
-
-
Save chrishaid/e958500d7735268b292a5c1b811b78eb to your computer and use it in GitHub Desktop.
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
# Load packages | |
require(googlesheets) | |
require(dplyr) | |
require(igraph) | |
require(ggraph) | |
# get spreadsheet | |
x <- gs_title("Data Whiz Tool Tracker Sheet") | |
# get data from Product Matrix Sheet | |
gs <- x %>% gs_read_csv("Product Matrix", skip = 2) | |
# Get unique organizations | |
cmos<-unique(gs$Organization) | |
# Pull Org, Product, Use and and Subj | |
relations <- gs %>% select(Organization, Product, Use, Subj = Subject.s.) | |
# create igraph object from relations. first column is to, second is from in the | |
# directed graph | |
d<-graph_from_data_frame(relations, directed = FALSE, vertices = NULL) | |
# add degrees attribure to each vertice | |
V(d)$degrees <- degree(d, mode = 'in') | |
# add CMO status to each vertice. | |
V(d)$cmo <- names(V(d)) %in% cmos | |
# Graph it! | |
ggraph(d, 'igraph', algorithm = 'kk') + | |
geom_edge_fan(aes(alpha = ..index..)) + | |
geom_node_point(aes(size = degrees, color=cmo)) + | |
geom_node_text(aes(angle = nAngle(x, y), label = name), | |
size=3, hjust='outward', check_overlap = TRUE) + | |
scale_edge_alpha('Uses', guide = 'edge_direction') + | |
scale_color_manual(values = c("gray40", "hotpink")) + | |
theme_bw() + | |
theme(panel.border = element_blank(), | |
panel.margin = element_blank(), | |
panel.grid = element_blank(), | |
axis.ticks = element_blank(), | |
axis.text = element_blank(), | |
axis.title = element_blank()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment