# To run this demo, you need to have the following software # on your machine: # # R r-project.org # ggobi ggobi.org # configured with the argument --with-plugins or --with-graphlayout # graphviz graphviz.org # Rggobi ggobi.org # graph, SNAData bioconductor.org library(Rggobi) library(graph) library(SNAData) data(business) data(marital) data(florentineAttrs) # Small problem with missings; eliminate the column # with missing values for now. florentineAttrs = florentineAttrs[,-2] # # Set up the data frame for nodes # nodes = nodes(business) nnodes = length(nodes) # Node data: families families = florentineAttrs # Add "degree" as an additional node variable Degree = degree(business) families = cbind(families, Degree) # Edges: business relationships e = t(edgeMatrix(business)) nedges = dim(e)[1] edgesb = cbind(nodes[e[,1]], nodes[e[,2]]) enames = paste(nodes[e[,1]], nodes[e[,2]], sep="->") # Add some edge weights: the sum of the two node degrees weights = Degree[e[,1]] + Degree[e[,2]] ebusiness = matrix(weights, ncol=1) dimnames(ebusiness) = list(enames, c("weight")) # Second edge set: marital relationships e = t(edgeMatrix(marital)) nedges = dim(e)[1] edgesm = cbind(nodes[e[,1]], nodes[e[,2]]) enames = paste(nodes[e[,1]], nodes[e[,2]], sep="->") weights = Degree[e[,1]] + Degree[e[,2]] emarital = matrix(weights, ncol=1) dimnames(emarital) = list(enames, c("weight")) # Start ggobi with both edge sets gg = ggobi(families) d2 = gg$setData(ebusiness, name="business") gg$setEdges(edgesb, edgeset=gg[["business"]]) d2 = gg$setData(emarital, name="marital") gg$setEdges(edgesm, edgeset=gg[["marital"]]) # You'll see a scatterplot of 'Number of Ties' against 'Wealth' # for each of the families. Use the Tools menu in ggobi to open # the GraphLayout plugin. Perform a neato layout with 'business' # as the edge set, and again with 'marital' as the edge set. # Use Identification in the scatterplot to look at the ties of the # wealthiest families.