if (interactive()) {
# Data frame of nodes
people <- data.frame(id=1:4, label=c("juan", "pedro", "matthew", "carlos"),
stringsAsFactors=F)
# Data frame of edges
relations <- data.frame(source=c(1,1,1,2,3,4,2,4,4),
target=c(4,2,3,3,4,2,4,1,1))
# Building gexf graph
mygraph <- gexf(nodes=people, edges=relations)
# Summary and pring
summary(mygraph)
write.gexf(mygraph, output="mygraph.gexf", replace=TRUE)
# Plotting
plot(mygraph)
}
Run the code above in your browser using DataLab