R igraph契约顶点字符属性

时间:2017-01-29 16:48:13

标签: r igraph

我正在使用Visual Studio R工具(CRAN R 3.3.2)igraph 1.0.0契约函数来使用vertex.attr.comb = "first"合并图形中的一些顶点。 它适用于数字属性,但对于字符属性,属性更改为列表。其中一个属性是形状。 合同tkplot失败后,因为V(g)$shape是一个列表。

我有一个带有属性的图g:

data.frame(a = vertex_attr_names(g), b = unlist(lapply(vertex_attr_names(g), function(x) mode(vertex_attr(g, x, V(g))))))
                   a         b
1             Period character
2       Organization character
3     EmplPermanence character
4           EmplType character
5       FullParttime character
6  JobClassification character
7             Gender character
8                Age character
9          Education character
10    PersonnelCount   numeric
11            source character
12             index   numeric
13        graphlevel   numeric
14              kind character
15              name character
16             value   numeric
17             layer   numeric
18             color character
19              type   logical
20            status character
21               aka character
22         completed   logical
23            branch   numeric
24        branchname character
25             shape character
26              size   numeric

我用

test <- contract(g, NewVertices, "first")

并查看属性:

data.frame(a = vertex_attr_names(test), b = unlist(lapply(vertex_attr_names(test), function(x) mode(vertex_attr(test, x, V(test))))))
                   a       b
1             Period    list
2       Organization    list
3     EmplPermanence    list
4           EmplType    list
5       FullParttime    list
6  JobClassification    list
7             Gender    list
8                Age    list
9          Education    list
10    PersonnelCount numeric
11            source    list
12             index numeric
13        graphlevel numeric
14              kind    list
15              name    list
16             value numeric
17             layer numeric
18             color    list
19              type    list
20            status    list
21               aka    list
22         completed    list
23            branch numeric
24        branchname    list
25             shape    list
26              size numeric
27             round numeric

当我尝试在测试中使用tkplot时:

lbl <- vertex_attr(test, "index", V(test))
lbl <- unlist(lbl)
> tkplot(test, layout = coord, vertex.label = lbl,
+             vertex.label.family = "sans", vertex.label.cex = 0.8,
+             edge.width = 2, edge.arrow.size = 0.5, edge.arrow.width = 0.5)
Error in as.tclObj(x, drop = TRUE) : cannot handle object of mode 'list'

我还没找到方法。有人可以帮忙吗?

0 个答案:

没有答案