从R中的度函数下载数据

问题描述 投票:-1回答:1

我使用ready函数度,如何获取顶点(结果在顶部)

0 1 2 3 4 5 7 10 6 9 12 15 14 11

函数返回结果,对于分析我也需要底部

> measure1<-degree(g1)
    > measure1
     0  1  2  3  4  5  7 10  6  9 12 15 14 11 
     3  5  1  3  2  1  4  3  2  3  1  2  1  1 
g1 <-read.table(listcsv[k])
g1 <- graph.data.frame(g1,directed=FALSE)
0 1
0 6
0 9
1 6
1 7
1 12
1 15
2 7
3 4
3 10
3 14
4 9
5 9
7 10
7 11
10 15
r igraph
1个回答
0
投票

欢迎来到Stack Exchange并感谢您的提问。不过我建议您阅读有关qazxsw poi的内容。获得答案的可能性更高。

根据您的问题,minimal reproducible example包的degree函数返回一个命名向量,其中向量值的名称是漩涡。请看下面的例子:

igraph

输出:

library(igraph)
actors <- data.frame(name=c("Alice", "Bob", "Cecil", "David",
                            "Esmeralda"),
                     age=c(48,33,45,34,21),
                     gender=c("F","M","F","M","F"))
relations <- data.frame(from=c("Bob", "Cecil", "Cecil", "David",
                               "David", "Esmeralda"),
                        to=c("Alice", "Bob", "Alice", "Alice", "Bob", "Alice"),
                        same.dept=c(FALSE,FALSE,TRUE,FALSE,FALSE,TRUE),
                        friendship=c(4,5,5,2,1,1), advice=c(4,5,5,4,2,3))
g <- graph.data.frame(relations, directed=TRUE, vertices=actors)
r <- degree(g)

# extraction of degree(g) names (vortices)
d <- data.frame(degrees = degree(g), nms = names(r))
d
© www.soinside.com 2019 - 2024. All rights reserved.