[R] create a network for a small text df

Elahe chalabi ch@|@b|@e|@he @end|ng |rom y@hoo@de
Wed Jan 30 11:15:44 CET 2019


Hi all,

I have a small dataframe and I would like to show in a network plot how words are related to the word "problem" with arrows (keeping the order of the words in sentences).
Here's the df:

     
     dput(df) 
     structure(list(text = structure(c(1L, 7L, 3L, 4L, 5L, 6L, 2L), .Label = c("account block solv problem", 
     "exactly problem morning", "investigate similar problem", "matched problem control vec",      "problem also accour yesterday", "same problem jj ", "same problem uk" 
      ), class = "factor")), class = "data.frame", row.names = c(NA, 
    -7L))

So far I have tried plotting each row a a network as following:


    
  library(igraph)
  net=graph(c("account","block","block","solve","solve","problem"))
  plot(net)

but I will end up having 7 plots, is there a better way?
thanks for any help.
Elahe.



More information about the R-help mailing list