How to have one line for duplicates value in igraph plot in R?

I have a data frame with three columns that want to have igraph plot for it. The first column has duplicate values when I visualize by igraph it makes two lines. But, I want to be just one line for duplicates values.

this is the reproducible data:

structure(list(NMSUKU = c("Aceh/ Achin/ Akhir/ Asji/ A-Tse/ Ureung Aceh", 
"Alas", "Aneuk Jamee", "Gayo", "Gayo Lut", "Gayo Luwes", "Gayo Serbe Jadi", 
"Kluet", "Sigulai", "Simeulue", "Simeulue", "Simeulue", "Singkil", 
"Singkil", "Tamiang"), TopLang = c("Aceh/ Acheh/ Achi ", "Alas ", 
"Aceh Jamee ", "Gajo/ Gayo ", "Gajo/ Gayo ", "Gajo/ Gayo ", "Gajo/ Gayo ", 
"Aceh Kluet ", "ERROR  TopCol out of range ", "Long Bano/ Simalur/ Simeuloe/ Simeulue/ Simulul ", 
"Aceh Simeleu Barat ", "Aceh Simeleu Tengah ", "Aceh Hulu Singkil ", 
"Aceh Hulu Singkil ", "Tamiang "), Ethnicity = c("1_Aceh/ Achin/ Akhir/ Asji/ A-Tse/ Ureung Aceh  ", 
"2_Alas  ", "3_Aneuk Jamee  ", "4_Gayo  ", "6_Gayo Luwes  ", 
"5_Gayo Lut  ", "7_Gayo Serbe Jadi  ", "8_Kluet  ", "NA  ", "10_Simeulue  ", 
"10_Simeulue  ", "10_Simeulue  ", "11_Singkil  ", "17_Batak Pakpak Dairi  ", 
"12_Tamiang  ")), row.names = c(NA, -15L), class = "data.frame")

I ran these codes:

m <- as.matrix(sample)
g <- graph_from_edgelist(rbind(m[,1:2], m[,2:3]), directed = TRUE)
l <- layout_with_sugiyama(g)
plot(g, layout=-l$layout[,2:1],
     edge.arrow.size = 0.1,
     vertex.size = 2.5,
     vertex.color = "grey",
     vertex.label.dist = 1,
     edge.arrow.width = 1.5,
     edge.width = seq(0.5,0.08),
     edge.lty = "solid",
     edge.color = "gray",
     vertex.label.cex = 0.7,
     is.rm = TRUE,
     vertex.label.color = "black")

This is what I got


I want to have one line from Singkil to Aceh Hulu Singkil
Thank for you heling.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.