Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Rug hogan-10-03-2012

7,312 views

Published on

These are my slides from a presentation to the Chicago R User Group on Oct 3, 2012. It covers how to use R and Gephi to visualize a map of influence in the history of philosophy.

More detail is available on the Design & Analytics Blog.

Published in: Technology
  • Be the first to comment

Rug hogan-10-03-2012

  1. 1. R, IGRAPH, ANDHANDSOME GRAPHS &
  2. 2. OVERVIEW
  3. 3. HISTORY OF PHILOSOPHY•••
  4. 4. GET THE DATA: THE QUERY• # Create the query qq <- SELECT * WHERE { – ?p a <http://dbpedia.org/onto logy/Philosopher> . ?p <http://dbpedia.org/onto logy/influenced> – ?influenced. } – # Use it in SPARQL• data <- SPARQL(url=http://dbped ia.org/sparql,query=qq)
  5. 5. GET THE DATA: CLEANING• # Prep to make it directed orig <- unlist(data$results[[2]], use.names=F) dest <- unlist(data$results[[1]], & use.names=F) # Turn URLs into readable names• orig <- url2names(orig) – dest <- url2names(dest) – # Format as an edge graph. edges <- data.frame(cbind(as.matrix(orig),as. matrix(dest), rep(1,length(orig))), stringsAsFactors=F) # TADA!
  6. 6. R TOOLS• – – –
  7. 7. USING IGRAPH• g <- graph.data.frame(edges, direct=TRUE, vertices=NULL) – – SNAbasics <- function(X) { – V(X)$label <- V(X)$name comps <- leading.eigenvector.community(X, – options=list(naive=F))$membership• colbar <- rainbow(max(comps)+1) V(X)$color <- colbar[comps+1] – # REMOVE OPACITY • V(g) <- values V(X)$color <- substr(V(X)$color,1,7) • set.vertex.attrib RPageRank <- page.rank(X, vids=V(X), ute(g,values) directed=TRUE, – options=list(maxiter=10000,eps=0.0001))$ve ctor V(X)$RPageRank <- RPageRank*1000 V(X)$size <- RPageRank*1000 – V(X)$Katz <- evcent(X)$vector*1000 print(length(unique(comps))) return(X) }
  8. 8. VISUALIZATION LAYOUTS
  9. 9. R VISUALIZATION OPTIONS
  10. 10. R2OTHER• –• –• –• – – python -m SimpleHTTPServer 8000 • •
  11. 11. GRAPH DATABASES• – –• – – –
  12. 12. TO GEPHI•• – • write.graph(g, file=gephi.GML, format=GML) –
  13. 13. TO GRAPHVIZ (WITH DOT)••••
  14. 14. JSON -> D3•• – – –• – As.numeric – stringsAsFactors =FALSE –
  15. 15. GEPHI -> SIGMA.JS•••
  16. 16. HAIRBALLS AND HIVES••
  17. 17. INTERACTIVE HAIRBALLS?•• –••
  18. 18. CHALLENGES!• graph2web() – – • PlotInMyBrowser(mydata,myport) –• –•
  19. 19. THANKS••••

×