我想用ggplot2可视化igraph对象的度数分布。因为ggplot2不采用由I 生成的简单数字向量将其转换为频率表。然后我将它传递给. 我仍然得到:我无法将表格列设置为因子,因为我还需要在对数刻度上绘制它。degree()
ggplot()
geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?
degree
library(igraph)
library(ggplot2)
g <- ba.game(20)
degree <- degree(g, V(g), mode="in")
degree
# [1] 6 2 7 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0
degree <- data.frame(table(degree))
degree
# degree Freq
# 1 0 13
# 2 1 4
# 3 2 1
# 4 6 1
# 5 7 1
ggplot(degree, aes(x=degree, y=Freq)) +
geom_line()
# geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?