从R中的degree函数下载数据
我使用就绪函数度, 如何获取顶点(顶部的结果) 该函数返回结果,对于分析,我还需要底部部分从R中的degree函数下载数据,r,igraph,R,Igraph,我使用就绪函数度, 如何获取顶点(顶部的结果) 该函数返回结果,对于分析,我还需要底部部分 > 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 欢迎使用Stack Exchange,谢谢您的提问。不过,我建议您阅读。得到答案的概率会更高 对于您的问题,igraph程序
> 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
欢迎使用Stack Exchange,谢谢您的提问。不过,我建议您阅读。得到答案的概率会更高 对于您的问题,
igraph
程序包的degree
函数返回一个命名向量,其中向量值的名称为漩涡。请参见下面的示例:
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
1) 使用程序包中的函数时,请使用
库(pkgname)
启动代码。2) 在问题中,张贴创建g1
的最小代码。问题不是很清楚。什么是g1
?你从哪里获得的学位
功能?在@kubazoo的帖子中编辑,你从哪里获得的学位
功能?您应该提到function.data.frame(Vertex=V(g1),Degree=Degree(g1))的包名或共享源代码。我希望就是这样。
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
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
degrees nms
Alice 4 Alice
Bob 3 Bob
Cecil 2 Cecil
David 2 David
Esmeralda 1 Esmeralda