I'm trying to created a directed network graph in R. To do this I need to create a matrix of what nodes are connected.
SOURCE_SUBREDDIT TARGET_SUBREDDIT LINK_SENTIMENT
rddtgaming rddtrust 1
xboxone battlefield_4 1
ps4 battlefield_4 1
fitnesscirclejerk leangains 1
fitnesscirclejerk lifeprotips 1
cancer fuckcancer 1
jleague soccer 1
bestoftldr tifu 1
quityourbullshit pics 1
bestof confession 1
anarchychess funny 1
internet_box ama 1
fitnesscirclejerk nofap 1
ffxiv ffxivapp 1
switcharoo funny 1
bitcoinmining bitcoin 1
subredditdrama nfl -1
rddtgaming rddtrust -1
As you can see above, the first and last pair have the same subredits. The data is showing the directional relationships between subreddits, which is why there are multiple pairs
Please see the photo for what I want the output to look like:
My code so far:
#reading in csv file
mydata <- read.csv(file="C:/Users/bmpmap/Documents/School/Netowrk Analysis/Connections List.csv", header=TRUE, sep=",")
colnames(mydata)
#SOURCE_SUBREDDIT TARGET_SUBREDDIT LINK_SENTIMENT
#install.packages("splitstackshape")
library(splitstackshape)
mydata_id = getanID(mydata , c("SOURCE_SUBREDDIT", "TARGET_SUBREDDIT", "LINK_SENTIMENT"))
colnames(mydata_id)
#reshaping data
I create an ID variable in the code above. I think I should be using this to uniquely identify the pairs