[R] create a network for a small text df

Elahe chalabi ch@|@b|@e|@he @end|ng |rom y@hoo@de
Fri Feb 1 10:31:31 CET 2019


Thanks for your reply but it does not solve the problem. Since I have 7 text rows in my df then I have to run something like 
net2=graph(c("account","block","block","solve","solve","problem")) for each, I'm looking for a way to bring all the relations in one single plot 



On Thursday, January 31, 2019 3:24 PM, Bill Poling <Bill.Poling using zelis.com> wrote:



Hello Elahe, this probably does not help but my idea may move you forward?


################################################################# NEW TOPIC ##############################################################################
#From: R-help <r-help-bounces using r-project.org> On Behalf Of Elahe chalabi via R-help Sent: Wednesday, January 30, 2019 5:16 AM

# I ran this
net1 <- 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))

#And I ran this

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

# I do not get 7 plots, only one? See attached.

WHP

From: R-help <r-help-bounces using r-project.org> On Behalf Of Elahe chalabi via R-help
Sent: Wednesday, January 30, 2019 5:16 AM
To: R-help Mailing List <r-help using r-project.org>
Subject: [R] create a network for a small text df

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.

______________________________________________
mailto:R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see

https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Confidentiality Notice This message is sent from Zelis. ...{{dropped:7}}



More information about the R-help mailing list