library(tidyverse)
library(rethinking)
data("Monks")
<- Monks d
To cite Federica’s work please use:
Gazzelloni F. (2023), Data Visualization: Network Monks data
"amount of reciprocity in - like - nominations within dyads"
" Nominations by 18 monks living in the same monastery over three time periods."
"#30DayChartChallenge day17: Network | DataViz: Federica Gazzelloni"
<- d%>%
d1 select(!contains("dis"),-A,-B) %>%
mutate(name=paste0(A_name,"-",B_name))%>%
select(-A_name,-B_name)%>%
distinct()%>%
filter(like_AB>0,like_BA>0)
%>% head() d1
library(igraph)
<- graph_from_data_frame(d1)
g <- as_adjacency_matrix(g)
y <- graph_from_adjacency_matrix(y)
sng <- layout_nicely(sng)
lx <- "#dfd1bf"
vcol
set.seed(1973)
plot(sng ,
layout=lx ,
vertex.size=12 ,
edge.arrow.size=0.5 ,
edge.width=2 ,
edge.curved=0.35 ,
vertex.color=vcol ,
edge.color="#6b493e" ,
asp=0.9,
margin = -0.05 ,
vertex.label=d1$name,
vertex.label.cex = 0.7)
library(showtext)
library(sysfonts) # this is included in showtext
font_add_google("Pacifico", "Pacifico")
showtext.auto()
library(cowplot)
ggdraw()+
draw_image("network.png",scale = 0.9,y=-0.05)+
draw_label("Amount of reciprocity in - like - nominations within 18 monks",
x=0.5,y=0.95,fontfamily="Pacifico",size=44)+
draw_label("living in the same monastery over three time periods.",
x=0.5,y=0.90,fontfamily="Pacifico",size=44)+
draw_label("#30DayChartChallenge day17: Networks | DataViz: Federica Gazzelloni",
x=0.5,y=0.05,size=20,fontfamily="Pacifico")
ggsave("d17_networks.png",width = 7,height = 5,bg="white",dpi=320)