-1

The first column in this dataframe represents the Twitter screenName. The second column contains the @mentions in the tweet. There could be more than one @mention in this column.

The dataframe looks like this

When I plot it I get the V1 nodes connected to a vector not each element in the yy1 vector

The graph looks like this

How can i show the connections between each node and each element?

Jaap
  • 81,064
  • 34
  • 182
  • 193
Bruce
  • 3
  • 2
  • Do not post your data as an image, please learn how to give a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610) – Jaap Dec 30 '15 at 09:34
  • Thank you Jaap. Will do next time. – Bruce Dec 31 '15 at 06:31

1 Answers1

1

You could try it like this

library(igraph)
library(data.table)
library(splitstackshape)
dt <- data.table(V1=c("from1", "from2", "from3"), 
                 yy1=c("@to1, @to2", "@to3, @to4", "@to5"))
dt <- cSplit(dt, 2, ", ", "long")[, yy1:=sub("@", "", yy1, fixed=T)]
dt %>% graph_from_data_frame %>% plot

enter image description here

lukeA
  • 53,097
  • 5
  • 97
  • 100