Social Network Analysis in RStudio
1) This week we have something pretty simple. Get a Social Network visualization to display on RStudio. We were even given the code for this to run. Lets go and take a look at it
> #LIS 4317 Module 12
>
> #install packages comment when not installing
> #install.packages("GGally")
> #install.packages("network")
> #install.packages("sna")
>
> #library
> library(GGally)
> library(network)
> library(sna)
> library(ggplot2)
>
> net = rgraph(10, mode = "graph", tprob = 0.5)
> net = network(net, directed = FALSE)
> network.vertex.names(net) = letters[1:10]
> ggnet2(net)
> ggnet2(net, node.size = 6, node.color = "black", edge.size = 1, edge.color = "grey")
| |
|
2) The code that was given was actually missing a few packages that need to be downloaded first in order to work but that is all that was missing. Taking a look at the code we can dissect a few things that control visual that it creates. The code actually generates a social network analysis (SNA) visualization using GGally's ggnet2. It creates a random undirected network graph with 10 nodes and visualizes it. Here’s what each part does: "rgraph" generates a random adjacency matrix for the graph. "network" converts it into a network object. "network.vertex.names" assigns labels a-j to the nodes. "ggnet2" creates the plot with customizable node and edge aesthetics. The result is a customizable network diagram where nodes represent entities and edges their connections.
3) Overall I think that making this social network visual came out to be a success. I know that this is a short post, but that is all I have for this week. I hope you enjoyed.
Comments
Post a Comment