igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] question about edge weights


From: Jessie Gunter
Subject: Re: [igraph] question about edge weights
Date: Mon, 16 Jul 2012 14:55:08 -0400

The nodes are the first two columns (ID and var).  These represent survey respondents and their contacts.

questionE = data.frame(Combined[c(grep("Hh_23e_*", colnames(Combined)))], whole_data$hhrn, whole_data$Site)
#hhrn is unique ID
#Site is one of four locations where data was taken
#need to weight the network according to the values for question E (frequency of contact; more frequent contact = more weight)
E_melted23 = questionE[questionE$whole_data.Site == 23,]
E_melted23 = melt.data.frame(E_melted23, id.vars=c('whole_data.hhrn', 'whole_data.Site'))
E_melted23 = data.frame(E_melted23$whole_data.hhrn, E_melted23$variable, E_melted23$value)

E23_new<-data.frame(id=E23[,1],var=E23.contacts,value=E23.recode)

>
> > head(E23_new)
> id var value
> 1 23002 Chief 4
> 2 23003 Chief 4
> 3 23004 Chief 3
> 4 23005 Chief 3
> 5 23006 Chief 3
> 6 23007 Chief 2

The edges are the values column [,3], but they aren't weighted.  Does this help to clarify?

Thank you!

On Mon, Jul 16, 2012 at 2:27 PM, Tamás Nepusz <address@hidden> wrote:
Hello Jessie,

How are the nodes and edges defined in your graph and what is their relation to the data frame?
--
T.


On Monday, 16 July 2012 at 19:51, Jessie Gunter wrote:

> Hello,
>
> I am using igraph to reshape a dataframe and create a graph with weighted edges between nodes. I melted the dataframe and used this...
>
> > E23_new<-data.frame(id=E23[,1],var=E23.contacts,value=E23.recode)
>
> to make the dataset look like this:
>
> > head(E23_new)
> id var value
> 1 23002 Chief 4
> 2 23003 Chief 4
> 3 23004 Chief 3
> 4 23005 Chief 3
> 5 23006 Chief 3
> 6 23007 Chief 2
>
> I am trying to make the "value" column the edge weights. I had no luck with this:
>
> g <- set.edge.attribute(g, "weight", value=E23.recode)
>
> How can I weight the edges according to the number in the value column? Right now they are all weighted 1.0.
>
> Any help would be greatly appreciated. Thanks in advance.
>
> -Jessie
> _______________________________________________
> igraph-help mailing list
> address@hidden (mailto:address@hidden)
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>




_______________________________________________
igraph-help mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help


reply via email to

[Prev in Thread] Current Thread [Next in Thread]