create a network for a small text df

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

create a network for a small text df

R help mailing list-2
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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: create a network for a small text df

R help mailing list-2
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 <[hidden email]> wrote:



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


################################################################# NEW TOPIC ##############################################################################
#From: R-help <[hidden email]> 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 <[hidden email]> On Behalf Of Elahe chalabi via R-help
Sent: Wednesday, January 30, 2019 5:16 AM
To: R-help Mailing List <[hidden email]>
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:[hidden email] 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}}

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: create a network for a small text df

Jeff Newmiller
I an finding your question very opaque. For one thing, why aren't you specifying any edges? Since I don't do this kind of analysis normally I don't know what your combined graph should look like. Can you provide a link you what you hope to end up with?

Note that the Posting Guide emphasizes that the topic here is R... not the theory behind what specific packages or analyses require... so you need to be more explicit here than you have been so far.

On February 1, 2019 1:31:31 AM PST, Elahe chalabi via R-help <[hidden email]> wrote:

>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
><[hidden email]> wrote:
>
>
>
>Hello Elahe, this probably does not help but my idea may move you
>forward?
>
>
>################################################################# NEW
>TOPIC
>##############################################################################
>#From: R-help <[hidden email]> 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 <[hidden email]> On Behalf Of Elahe chalabi
>via R-help
>Sent: Wednesday, January 30, 2019 5:16 AM
>To: R-help Mailing List <[hidden email]>
>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:[hidden email] 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}}
>
>______________________________________________
>[hidden email] 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.

--
Sent from my phone. Please excuse my brevity.

______________________________________________
[hidden email] 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.