Labels do not show in output file
Maybe I'm missing something, but the following code does not produce an output with the proper labels (and, also, an error)
...r code... people <- data.frame(c(1:4), c('juan', 'pedro', 'matthew', 'carlos')) relations <- data.frame(source=c(1,1,1,1), target=c(2,3,4,2)) write.gexf(nodes=people, edges=relations)
..gexf output
<?xml version="1.0" encoding="UTF-8"?>
<gexf xmlns="http://www.gexf.net/1.2draft" xmlns:viz="http://www.gexf.net/1.1draft/viz" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd" version="1.2">
<meta lastmodifieddate="2014-03-08">
<creator>NodosChile</creator>
<description>A graph file writing in R using "rgexf"</description>
<keywords>gexf graph, NodosChile, R, rgexf</keywords>
</meta>
<graph mode="static">
<nodes>
<node id="1" label="2"/>
<node id="2" label="2"/>
<node id="3" label="2"/>
<node id="4" label="2"/>
</nodes>
<edges>
<edge id="0" source="1" target="2" weight="1.0"/>
<edge id="1" source="1" target="3" weight="1.0"/>
<edge id="2" source="1" target="4" weight="1.0"/>
<edge id="3" source="1" target="2" weight="1.0"/>
</edges>
</graph>
</gexf>
Warning message:
In [<-.data.frame
(*tmp*
, , tofix, value = list(2, 4, 3, 1)) :
provided 4 variables to replace 1 variables
Comments (6)
-
-
Hi Tim, it seems that your code produce objects of the class factor. Try with:
people <- data.frame(id=c(1:4), label=c('juan', 'pedro', 'matthew', 'carlos'), stringsAsFactors=F)
... it should work as you expected
Best,
Jorge
-
reporter Thank you Jorge. You are correct. This was the source of the problem.
(I wish I had figured this out yesterday, lol. I resorted to writing custom code to export to an excel file for loading into Gephi)
-
Thanks Jorge
-
repo owner Several users have got confused with this issue. Please refer to the package manual, specifically to the keepFactors option. For the next version I will set the default option of -keepFactors- as -FALSE-. Either way I will include a warning message whenever factors are used and the
-
repo owner - changed status to resolved
Fixed, version 0.14* includes a warning message.
- Log in to comment
Hi , Tim
It seems I get the same issue . The Example 1 at Project Home page already contains the problem .
Where the "juan" ?
It reproduced for me by labels' nodes aren't set properly at GEXF file.