Module # 12
Issaiah. Jennings
Module # 12
For this project, I explored how to visualize a simple social network using RStudio. Instead of using NodeXL in Microsoft Excel, I chose to use RStudio because I’m more comfortable with it and wanted to try out the ggnet2 function from the GGally package, which works well with ggplot2.
install.packages("GGally")
install.packages("network")
install.packages("sna")
install.packages("ggplot2")
library(GGally)
library(network)
library(sna)
library(ggplot2)
# Create a random adjacency matrix for 10 nodes
net_matrix = rgraph(10, mode = "graph", tprob = 0.5)
# Convert the matrix into a network object
net = network(net_matrix, directed = FALSE)
# Assign names to each node (a to j)
network.vertex.names(net) = letters[1:10]
ggnet2(net)
ggnet2(net,
node.size = 6,
node.color = "black",
edge.size = 1,
edge.color = "grey")
ggnet2(net, size = 6, color = rep(c("tomato", "steelblue"), 5))
>
Successes
I was able to install all the packages without errors.
The network plotted successfully using ggnet2.
I learned how to customize the graph using node size and color settings.
I forgot to install the sna package at first, which caused an error when using rgraph(), but once installed, it worked fine.
Understanding how rgraph() creates random graphs took a minute, but reading the documentation helped.
This project helped me understand how social networks can be visualized using R. Even though the network was randomly generated, I now know how to structure and style network plots. In the future, I would like to use real-world data, like social media or organizational connections, to create more meaningful visualizations.

Comments
Post a Comment