Newbie to R here. I am trying to plot a network diagram with the code shown below. But when I specify the vertex size, the edges disappear. The with and without vertex specification and the resultant plot is shown below.
Without vertex size:
#NSW
clean_nsw <- clean %>%
filter(State=="NSW")
clean_nsw$CountryID.Origin <- str_to_title(clean_nsw$CountryID.Origin)
nsw_plot <- graph.data.frame(d=clean_nsw, directed=T)
plot.igraph(nsw_plot,
edge.color='grey23',
vertex.color='deepskyblue2',
edge.width=1,
vertex.label.color='gray0',
vertex.label.cex=0.75,
vertex.label.family="Helvetica",
vertex.label.font=2,
arrow.width=(clean_nsw$s_count*1),
layout= layout_nicely)
without vertex size With vertex size specified
#NSW
clean_nsw <- clean %>%
filter(State=="NSW")
clean_nsw$CountryID.Origin <- str_to_title(clean_nsw$CountryID.Origin)
nsw_plot <- graph.data.frame(d=clean_nsw, directed=T)
plot.igraph(nsw_plot,
edge.color='grey23',
vertex.color='deepskyblue2',
edge.width=1,
vertex.size= clean_nsw$s_count*0.5,
vertex.label.color='gray0',
vertex.label.cex=0.75,
vertex.label.family="Helvetica",
vertex.label.font=2,
arrow.width=(clean_nsw$s_count*1),
layout= layout_nicely)
[image] https://i.stack.imgur.com/jH1oN.png
i'm not sure why when I insert the vertex size, the edges disappears. But here's the warning message that is shown:
2: In layout[, 1] + label.dist * cos(-label.degree) * (vertex.size + :
longer object length is not a multiple of shorter object length
3: In layout[, 2] + label.dist * sin(-label.degree) * (vertex.size + :
longer object length is not a multiple of shorter object length
Also, here is clean_nsw
# A tibble: 6 x 3
# Groups: State [1]
CountryID.Origin State s_count
<chr> <chr> <int>
1 Thailand NSW 67
2 China NSW 51
3 Singapore NSW 43
4 Indonesia NSW 36
5 Fiji NSW 32
6 Malaysia NSW 32
Any suggestions please?