[英]Edge-list Network graph R
I am stuck in drawing a graph on R. In particular, I would like to make a network graph as this我被困在 R 上绘制图形。特别是,我想像这样制作网络图
but with the central node of another color and the size of the other nodes as big as the column weights in the dataset.但是中心节点是另一种颜色,其他节点的大小与数据集中的列权重一样大。 The dataset is the following:数据集如下:
structure(list(owner = c("MASTERS", "MASTERS", "MASTERS", "MASTERS", "MASTERS", "MASTERS","MASTERS", "MASTERS"),
armed_band = c("Biakatu Communal Militia", "FPJC", "FRPI", "LRA", "Mayi Mayi Militia", "Mayi Mayi Militia (Safisha Mabaya)", "Mayi Mayi Militia (Simba)", "RCD"),
weigth = c(1, 1, 1, 5, 2, 1, 1, 1)),
row.names = c(NA, -8L),
class = c("tbl_df", "tbl", "data.frame"))
The code I am using at the moment is the following:我目前使用的代码如下:
aux_samearea_network <- read_excel("file")
concessions_network = network(aux_samearea_network,
matrix.type = "edgelist",
ignore.eval = FALSE,
names.eval = "weights" )
concessions_network %v% "Concession" = ifelse(
aux_samearea_network$armed_band %in% c("LRA",
"Mayi Mayi Militia",
"Biakatu Communal Militia",
"FPJC",
"FRPI",
"Mayi Mayi Militia (Safisha Mabaya)",
"Mayi Mayi Militia (Simba)",
"RCD"), "Armed Band", "Concession")
ggnet2(concessions_network,
node.size = "weights",
node.color = "lightblue",
edge.size = 1,
edge.color = "grey",
main = "Network concession MASTERS",
edge.label = "weights",
label = TRUE,)
Can anyone help me with this please?任何人都可以帮我解决这个问题吗? I would be extremely grateful.我将不胜感激。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.