Problems with node names in Igraph with R -
i have list of data.frames (dflist) i'd generate directed weighted networks in igraph in r. edge-weight variable "valueusd", while vertices identified numbers columns "reporter" , "partner". here follows function prepared called "write.graphs" used lapply on "dflist".
write.graphs<-function(filename){ d<-graph.data.frame(filename[c("reporter", "partner")], directed=true) d <- set.edge.attribute(d, "weight", value=filename$valueusd) } graphs<-lapply(dflist, write.graphs)
every thing work perfectly. if check vertex names get:
graphs[1]$names null
but troubles emerge when want utilize names in place of numbers identify vertices, using corresponding columns "reportern" , "partnern" in each of data.frames in dflist. here can see how data.frames like:
dflist[1] $`aug 2014` reporter yearperiod year period commodity partner netweightkg valueusd cost partnern reportern 1 76 201408 2014 8 150910 0 4472917 22028271 4.924811 world brazil 2 76 201408 2014 8 150910 32 380891 1533948 4.027262 argentine republic brazil 3 76 201408 2014 8 150910 152 239776 1336057 5.572105 republic of chile brazil 4 76 201408 2014 8 150910 251 289 2164 7.487889 french republic brazil 5 76 201408 2014 8 150910 300 27592 170658 6.185054 hellenic republic brazil 6
this message get:
> grafi<-lapply(dflist, scrivi.grafi) there 50 or more warnings (use warnings() see first 50) > warnings() warning messages: 1: in graph.data.frame(filename[c("reportern", "partnern")], ... : in `d' `na' elements replaced string "na" 2: in graph.data.frame(filename[c("reportern", "partnern")], ... : in `d' `na' elements replaced string "na" 3: in graph.data.frame(filename[c("reportern", "partnern")], ... :
if helps, checked:
class(dflist[1]$partnern) [1] "null"
any suggestion? can explain me happens?
thanks lot, umberto.
igraph names vertices
No comments:
Post a Comment