我有点奇怪,我必须在python中创建一个igraph对象,然后在R中对其进行后期处理。 我在cran上找到了rPython包,它允许我在R会话中执行python代码。在
在R中,我使用以下代码生成pythonigraph对象,并以graphml格式保存它。在
library(rPython)
library(igraph)
python.exec(c("from igraph import *",
"g = Graph(directed = True)",
"g.add_vertices(3)",
"g.add_edges([(0,1),(1,2)])",
"fn = './test.graphml'",
"g.write_graphml(fn)"))
现在,如果我尝试在与
^{pr2}$该会话将崩溃并返回以下错误消息:
*** caught segfault ***
address 0x59, cause 'memory not mapped'
Traceback:
1: .Call("R_igraph_read_graph_graphml", file, as.numeric(index), PACKAGE = "igraph")
2: read.graph.graphml(file, ...)
3: read.graph("./test.graphml", format = "graphml")
aborting ...
Segmentation fault (core dumped)
如果我启动一个新的R会话,我就可以用
^{pr2}$我的pythonigraph版本是0.7.0。以及R sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C LC_TIME=en_GB.UTF-8
[4] LC_COLLATE=en_GB.UTF-8 LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=en_GB.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] igraph_0.7.0 rPython_0.0-5 RJSONIO_1.3-0
loaded via a namespace (and not attached):
[1] tools_3.1.2
注意:我只有在运行ubuntu14.04时才会遇到这个问题,因为我找不到python igraph的最新版本0.7.1。我在macox中测试了相同的代码,其中python(通过mac端口)和R igraph版本都是0.7.1。效果很好。我想知道是否可以通过安装pythonigraph的0.7.1版本来解决这个问题。在
目前没有回答
相关问题 更多 >
编程相关推荐