0

I have a database.

I want to build a chord diagram similar to this one: https://i.stack.imgur.com/59JcJ.png

My code:

vertices <- data.frame(name = unique(c(as.character(imports$Partner), as.character(imports$Reporter))) )
mygraph <- graph_from_data_frame( imports, vertices=vertices )
from <- match( imports$Reporter, vertices$name)
to <- match( imports$Partner, vertices$name)
ggraph(mygraph, layout = 'dendrogram', circular = TRUE)  
    geom_conn_bundle(data = get_con(from = from, to = to), alpha=0.2, colour="skyblue", tension = 0) 
     geom_node_point(aes(filter = leaf, x = x*1.05, y=y*1.05)) 
     theme_void()

Result: https://i.stack.imgur.com/uY2Yq.png

I searched for all kinds of settings for the chord diagram, but I didn’t find, how to make the links of the same size, and set the number of lines as an indicator of the value. Does anyone know how to create such a diagram?

data=structure(list(Reporter = c("USA", "USA", "USA", "USA", "India", 
"Japan", "Japan", "USA", "Rep. of Korea", "USA", "Japan", "Japan", 
"Japan", "Rep. of Korea", "USA", "USA", "USA", "China", "USA", 
"USA", "Rep. of Korea", "USA", "Japan", "Japan", "Rep. of Korea", 
"China", "China", "Rep. of Korea", "India", "China", "Rep. of Korea", 
"USA", "Rep. of Korea", "Japan", "China", "Rep. of Korea", "India", 
"China", "China", "India", "China", "China"), Partner = c("Saudi Arabia", "Canada", "Venezuela", "Mexico", 
"Areas, nes", "Saudi Arabia", "United Arab Emirates", "Nigeria", 
"Saudi Arabia", "Iraq", "Iran", "Qatar", "Kuwait", "United Arab Emirates", 
"Angola", "Norway", "Colombia", "Oman", "United Kingdom", "Kuwait", 
"Iran", "Gabon", "Indonesia", "Oman", "Kuwait", "Angola", "Iran", 
"Oman", "Saudi Arabia", "Saudi Arabia", "Qatar", "Ecuador", "Indonesia", 
"China", "Indonesia", "Australia", "Nigeria", "Yemen", "Fmr Sudan", 
"Kuwait", "Iraq", "Viet Nam", "Iraq", "Australia", "Angola", 
"United Arab Emirates", "Argentina", "Iran", "Trinidad and Tobago", 
"Congo", "Yemen", "Iraq", "Viet Nam", "Australia", "Malaysia", 
"Mexico", "Indonesia", "China", "Congo", "Ecuador", "Malaysia", 
"Qatar", "Brunei Darussalam", "Norway"), Qty = c(69785202126, 68349221243, 68326932683, 
64923669168, 57159000064, 53691639675, 52396394737, 46817696134, 
38307387772, 31471382247, 25554794183, 19184268129, 18481591406, 
16695296617, 16497467586, 16029110463, 15953011573, 15660839936, 
14459452736, 13796910873, 11134838478, 10393629031, 10258716565, 
9751327665, 9417368771, 8636634112, 7000465408, 6586187350, 5769723904, 
5730211328, 5702528697, 5553458497, 5290777764, 5113191253, 4575188480, 
4361612670, 3888963072, 3612423424, 3313590784, 3223781888, 3183182080, 
3158472192, 3151280715, 3081015515, 3067260000, 2921931008, 2850134892, 
2607684096, 2587749446, 2547349198, 2485083122, 2443798762, 2365431992, 
2342513214, 2308853961, 2130664704, 1942125162, 1828376381, 1814260579, 
1785874000, 1609282280, 1598901888, 1534923974, 1477843712, 1476737920, 
1454356736, 1355873401, 1293729024, 1285355978, 1278701346, 1259876360, 
1252518912, 1248772992, 1223383808, 1163368000, 1144188000, 1108399232, 
1062041363, 1041526592, 977722731, 897418483, 877541040, 845556546, 
801940467, 744316800, 739848000, 724177472, 694896000, 685405539, 
672387008, 554965585, 540327751, 508204324, 4.87e+08, 457252032, 
433428000, 430473920, 426744352, 408635880, 392727578, 390598528, 
390189912, 389451923, 384376548, 350920922, 327039700, 285413702, 
285143680, 275486240, 274015471, 264478000, 260122000, 238997756, 
227806048, 204376795, 192144011, 150791409, 140634221, 135842986, 
130777039, 129973032, 125115000, 124681401, 123443000, 120061792, 
110795499, 106762492, 105548008, 84693986, 70275359, 57248174, 
47944463, 40236018, 30783728, 18364000, 13419253, 12551365, 9631763, 
5994199, 374000, 350000, 339115, 86420, 24000, 180)), class = c("tbl_df", 
"tbl", "data.frame"), row.names = c(NA, -145L))
Ryan M
  • 15,686
  • 29
  • 53
  • 64
Varlant1n
  • 1
  • 2
  • It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick May 19 '22 at 14:01

0 Answers0