I have data which represents transit between UK cities.
- Transit: if there is a transit between these two cities = 1, otherwise =0
- ave.pas: average number of passengers
.
library(plotly) library(ggraph) library(tidyverse) library(tidygraph) library(igraph) library(edgebundleR)
df2 <- data.frame (City1 = c("London", "London", "London", "London" ,"Liverpool","Liverpool","Liverpool" , "Manchester", "Manchester", "Bristol"),
City2 = c("Liverpool", "Manchester", "Bristol","Derby", "Manchester", "Bristol","Derby","Bristol","Derby","Derby"),
Transit = c(1,0,1,1,1,1,1,1,0,1),
ave.pas = c(10,0,11,24,40,45,12,34,0,29))
df:
City1 City2 Transit ave.pas
1 London Liverpool 1 10
2 London Manchester 0 0
3 London Bristol 1 11
4 London Derby 1 24
5 Liverpool Manchester 1 40
6 Liverpool Bristol 1 45
7 Liverpool Derby 1 12
8 Manchester Bristol 1 34
9 Manchester Derby 0 0
10 Bristol Derby 1 29
Now I plot circular network:
df <- subset(df2, Transit== 1, select = c("City1","City2"))
edgebundle(graph.data.frame(df),directed=F,tension=0.1,fontsize = 10)
My goal is to set the size or colour's intensitvity of edges based on the corresponding value in 'ave.pas' variable from the dataset