Learning Social Network Analysis in R
This week's module we work with social network analysis in R. At first this type of thing looks pretty weird and not really sure how it would be useful in analysis but then I realized how it shows relations. I fired up R studio and tried the code provided 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")
while that creates this cool little visual it doesn't really tell me much. Its not very useable like this so I now need to try to implement this with some data. As I am always trying to find ways to make senes out of my collected Zed Run data I decided to try to import a dataframe of my stable and find ways to build relations.
This was incredibly challenging as I learned I had to make a matrix to show similarities.The easiest would of been to simply connect horses by bloodline or simple characteristics. I decided to group horses by winrate with a threashold of 1.
The result gave ma few horses on islands by themselves. Here is the dataframe to help you understand the visualization sorted by WinRate.
HorseID | Name | WinRate | Bloodline | HorseType |
517208 | Sphinxx | 19.69 | Finney | Mare |
591430 | Grand Jefe | 15.13 | Buterin | Colt |
22295 | Red Light Green Light | 14.81 | Buterin | Mare |
589053 | Bondage | 14.63 | Buterin | Stallion |
521223 | Same Gamble | 14.29 | Buterin | Colt |
602693 | ManeSidePiece | 14.06 | Buterin | Colt |
400924 | Tyr the Brave | 12.69 | Nakamoto | Stallion |
498085 | Protonic | 12.66 | Szabo | Mare |
132975 | Breast In Breed | 11.5 | Buterin | Mare |
505039 | Pleasurable | 10.53 | Nakamoto | Mare |
436742 | No Donkey Left Behind | 10.07 | Szabo | Filly |
14751 | Limited Tier | 9.03 | Buterin | Stallion |
133962 | C h e e r i o ! | 8.47 | Szabo | Mare |
14435 | Trusting Starlight | 7.97 | Buterin | Mare |
600571 | E I E I O | 6.76 | Szabo | Colt |
76556 | Anime Princess | 6.67 | Szabo | Mare |
442758 | Irrational Spending | 5.36 | Buterin | Filly |
436743 | Cousin Luke | 5.32 | Buterin | Colt |
601535 | FailurIsNotAnOption | 4.5 | Buterin | Colt |
605743 | How Are My Brake Lights | 4.35 | Buterin | Filly |
392732 | Diamonds Edge | 3.96 | Szabo | Mare |
149466 | Best In Snow | 3.25 | Buterin | Colt |
604467 | Donkey In Chains | 2.63 | Buterin | Filly |
603066 | Junkyard Donkey | 2.44 | Buterin | Colt |
452140 | 2jzgte | 1.92 | Buterin | Filly |
29968 | Petergate | 0 | Buterin | Stallion |
As you see Petergate has 0% win rate so it is on his own island as well as Sphinxx who is almost 5% above the next horse.
After more research I realize that this is not the best use or example of social network analysis. Finding datasets were objects may have multiple relations with different strengths of relations would be a better use of this. However for simply showing realtionships this is was a fine example. I had the option of using Excel to show this how ever I rather work on my R skills or python skills versus doing these visulizations in R.