我坚持在 R 上绘制图表。特别是,我想制作一个网络图
但是使用另一种颜色的中心节点和其他节点的大小与数据集中的列权重一样大。数据集如下:
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"))
我目前使用的代码如下:
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,)
任何人都可以帮我解决这个问题吗?我将不胜感激。