LIS 4317 Module #12 Assignment
This week, I explored the basics of Social Network Analysis by creating my first network visualization using RStudio and the ggnet2 package. Here’s what I learned during the process.
What Worked:
- Installing the necessary libraries (GGally, network, sna, and ggplot2) was smooth.
- I was able to generate a basic network and customize it by adjusting node size, color, and edge width.
What Didn’t Work:
- At first, I forgot to convert the matrix created by rgraph() into a network object using the network() function, which caused an error in ggnet2.
- Another issue I faced was with labeling nodes—I initially tried to use numbers instead of letters, which didn’t render appropriately until I used network.vertex.names().
Key Takeaways:
- "ggnet2" is a powerful yet beginner-friendly tool for network visualization in R.
- This would be useful for presenting real-world social networks like Twitter conversations or organizational structures.
R Studio Code:
# Install necessary packages (run only once)
install.packages("GGally")
install.packages("network")
install.packages("sna")
install.packages("ggplot2")
# Load libraries
library(GGally)
library(network)
library(sna)
library(ggplot2)
# Generate a random undirected network of 10 nodes
net = rgraph(10, mode = "graph", tprob = 0.5)
net = network(net, directed = FALSE)
# Label nodes as letters a–j
network.vertex.names(net) = letters[1:10]
# Basic plot
ggnet2(net)
# Customized plot
ggnet2(net,
node.size = 6,
node.color = "black",
edge.size = 1,
edge.color = "grey")

Comments
Post a Comment