SlideShare a Scribd company logo
{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析
(node, vertex)
(edge, link)
{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析
0 1 0 0 0 0
0 0 1 0 0 0
0 0 0 0 1 0
0 1 0 0 0 0
0 0 0 1 0 1
0 0 0 0 0 0
A B
B C
C E
D B
E D
E F
{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析
#
whiskies <- data.table::fread("http://
outreach.mathstat.strath.ac.uk/outreach/nessie/datasets/
whiskies.txt", header = TRUE)
#
cor.mat <- whiskies %>%
select(Body, Sweetness, Smoky, Medicinal, Tobacco, Honey,
Spicy, Winey, Nutty, Malty, Fruity, Floral) %>%
t() %>%
cor()
#
colnames(cor.mat) <- whiskies$Distillery
rownames(cor.mat) <- whiskies$Distillery
#
cor.mat[upper.tri(cor.mat, diag = TRUE)] <- NA
cor.mat[1:5, 1:5]
Aberfeldy Aberlour AnCnoc Ardbeg Ardmore
Aberfeldy NA NA NA NA NA
Aberlour 0.7086322 NA NA NA NA
AnCnoc 0.6973541 0.5030737 NA NA NA
Ardbeg -0.1473114 -0.2285909 -0.1404355 NA NA
Ardmore 0.7319024 0.5118338 0.5570195 0.2316174 NA
# Long-Format 0.8
d <- cor.mat %>%
as.data.frame() %>%
mutate(distillerry1 = whiskies$Distillery) %>%
gather(key = distillerry2, value = cor, -distillerry1) %>%
select(distillerry1, distillerry2, cor) %>%
filter(!is.na(cor) & cor >= 0.80)
head(d)
distillerry1 distillerry2 cor
1 Auchroisk Aberfeldy 0.8238415
2 Benrinnes Aberfeldy 0.8419479
3 Benromach Aberfeldy 0.8554217
{tidygraph}と{ggraph}によるモダンなネットワーク分析
# tbl_graph
g <- as_tbl_graph(d, directed = FALSE)
g
# A tbl_graph: 67 nodes and 135 edges
#
# An undirected simple graph with 1 component
#
# Node Data: 67 x 1 (active)
name
<chr>
1 Auchroisk
2 Benrinnes
# tbl_graph
g <- as_tbl_graph(d, directed = FALSE)
g
# A tbl_graph: 67 nodes and 135 edges
#
# An undirected simple graph with 1 component
#
# Node Data: 67 x 1 (active)
name
<chr>
1 Auchroisk
2 Benrinnes
3 Benromach
4 BlairAthol
5 RoyalLochnagar
6 Speyside
# ... with 61 more rows
#
# Edge Data: 135 x 3
from to cor
<int> <int> <dbl>
1 1 54 0.824
2 2 54 0.842
3 3 54 0.855
# ... with 132 more rows
3 Benromach
4 BlairAthol
5 RoyalLochnagar
6 Speyside
# ... with 61 more rows
#
# Edge Data: 135 x 3
from to cor
<int> <int> <dbl>
1 1 54 0.824
2 2 54 0.842
3 3 54 0.855
# ... with 132 more rows
#
g %>% igraph::graph.density()
[1] 0.06105834
#
g %>% igraph::transitivity()
[1] 0.2797927
# ( 1)
g %>% igraph::reciprocity()
[1] 1
#
g <- g %>%
mutate(centrality = centrality_betweenness())
g
# A tbl_graph: 67 nodes and 135 edges
#
# An undirected simple graph with 1 component
#
# Node Data: 67 x 2 (active)
name centrality
<chr> <dbl>
1 Auchroisk 174.
2 Benrinnes 122.
3 Benromach 411.
#
g <- g %E>%
mutate(centrality = centrality_edge_betweenness())
g
# A tbl_graph: 67 nodes and 135 edges
#
# An undirected simple graph with 1 component
#
# Edge Data: 135 x 4 (active)
from to cor centrality
<int> <int> <dbl> <dbl>
1 1 54 0.824 79.3
2 2 54 0.842 42.9
3 3 54 0.855 54.2
#
g <- g %E>%
mutate(centrality = centrality_edge_betweenness())
g
# A tbl_graph: 67 nodes and 135 edges
#
# An undirected simple graph with 1 component
#
# Edge Data: 135 x 4 (active)
from to cor centrality
<int> <int> <dbl> <dbl>
1 1 54 0.824 79.3
2 2 54 0.842 42.9
3 3 54 0.855 54.2
#
g <- g %>%
mutate(community = as.factor(group_fast_greedy(weights = cor)))
g
# A tbl_graph: 67 nodes and 135 edges
#
# An undirected simple graph with 1 component
#
# Node Data: 67 x 2 (active)
name community
<chr> <fct>
1 Auchroisk 2
2 Benrinnes 3
3 Benromach 2
{tidygraph}と{ggraph}によるモダンなネットワーク分析
g %>%
ggraph(layout = "kk")
{tidygraph}と{ggraph}によるモダンなネットワーク分析
g %>%
ggraph(layout = "kk") +
geom_edge_link(aes(width = cor),
alpha = 0.8,
colour = "lightgray")
{tidygraph}と{ggraph}によるモダンなネットワーク分析
g %>%
ggraph(layout = "kk") +
geom_edge_link(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1))
{tidygraph}と{ggraph}によるモダンなネットワーク分析
g %>%
ggraph(layout = "kk") +
geom_edge_link(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1)) +
geom_node_point(aes(colour = community, size = degree))
{tidygraph}と{ggraph}によるモダンなネットワーク分析
g %>%
ggraph(layout = "kk") +
geom_edge_link(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1)) +
geom_node_point(aes(colour = community, size = degree)) +
geom_node_text(aes(label = name), repel = TRUE)
{tidygraph}と{ggraph}によるモダンなネットワーク分析
g %>%
ggraph(layout = "kk") +
geom_edge_link(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1)) +
geom_node_point(aes(colour = community, size = degree)) +
geom_node_text(aes(label = name), repel = TRUE) +
theme_graph()
{tidygraph}と{ggraph}によるモダンなネットワーク分析
g %>%
ggraph(layout = "kk") +
geom_edge_arc(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1)) +
geom_node_point(aes(colour = community, size = degree)) +
theme_graph(background = "grey20", text_colour = "white")
{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析
g %>%
mutate(degree = centrality_degree(),
community = as.factor(group_fast_greedy(weights = cor))) %>%
filter(degree >= 6) %E>%
filter(cor > 0.85) %>%
ggraph(layout = "lgl") +
geom_edge_link(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1)) +
geom_node_point(aes(colour = community, size = degree)) +
geom_node_text(aes(label = name), repel = TRUE) +
theme_graph()
g %>% ggraph(layout = "kk") +
geom_edge_fan(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1)) +
geom_node_point(aes(colour = community, size = degree)) +
geom_node_text(aes(label = name), repel = TRUE) +
theme_graph()
g %>% ggraph(layout = "linear") +
geom_edge_arc(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1)) +
geom_node_point(aes(colour = community, size = degree)) +
geom_node_text(aes(label = name), repel = TRUE) +
theme_graph()
{tidygraph}と{ggraph}によるモダンなネットワーク分析
g %>% ggraph(layout = "linear", circular = TRUE) +
geom_edge_arc(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1)) +
geom_node_point(aes(colour = community, size = degree)) +
geom_node_text(aes(label = name), repel = TRUE) +
theme_graph()
{tidygraph}と{ggraph}によるモダンなネットワーク分析
#
d <- whiskies %>%
select(Body, Sweetness, Smoky, Medicinal, Tobacco, Honey,
Spicy, Winey, Nutty, Malty, Fruity, Floral) %>%
dist()
#
hc <- hclust(d, method="ward.D2")
# tbl_graph
g <- as_tbl_graph(hc)
g %>%
ggraph(layout = "kk") +
geom_edge_link(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1)) +
geom_node_point(aes(colour = community, size = degree)) +
geom_node_text(aes(label = name), repel = TRUE) +
theme_graph()
{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析

More Related Content

PDF
{tidygraph}と{ggraph}による モダンなネットワーク分析(未公開ver)
PDF
Rでソーシャルネットワーク分析
PDF
{tidytext}と{RMeCab}によるモダンな日本語テキスト分析
PPTX
R seminar on igraph
PDF
Cmdstanr入門とreduce_sum()解説
PDF
Rで学ぶロバスト推定
PDF
Rの高速化
PDF
距離と分類の話
{tidygraph}と{ggraph}による モダンなネットワーク分析(未公開ver)
Rでソーシャルネットワーク分析
{tidytext}と{RMeCab}によるモダンな日本語テキスト分析
R seminar on igraph
Cmdstanr入門とreduce_sum()解説
Rで学ぶロバスト推定
Rの高速化
距離と分類の話

What's hot (20)

PDF
ベイズ推定の概要@広島ベイズ塾
PDF
線形計画法入門
PDF
決定木学習
PDF
ベータ分布の謎に迫る
PDF
一般化線形モデル (GLM) & 一般化加法モデル(GAM)
PPTX
Dimensionality reduction with t-SNE(Rtsne) and UMAP(uwot) using R packages.
PDF
実践で学ぶネットワーク分析
PDF
第4回DARM勉強会 (構造方程式モデリング)
PDF
LDA入門
PDF
Rでisomap(多様体学習のはなし)
PDF
ファクター投資と機械学習
PDF
Rにおける大規模データ解析(第10回TokyoWebMining)
PPTX
データサイエンス概論第一=3-3 回帰分析
PDF
計量経済学と 機械学習の交差点入り口 (公開用)
PDF
RでGPU使ってみた
PPTX
ブートストラップ法とその周辺とR
PPTX
Tokyo r #37 Rubin's Rule
PPTX
データサイエンス概論第一=2-1 データ間の距離と類似度
PDF
Rで階層ベイズモデル
PDF
星野「調査観察データの統計科学」第3章
ベイズ推定の概要@広島ベイズ塾
線形計画法入門
決定木学習
ベータ分布の謎に迫る
一般化線形モデル (GLM) & 一般化加法モデル(GAM)
Dimensionality reduction with t-SNE(Rtsne) and UMAP(uwot) using R packages.
実践で学ぶネットワーク分析
第4回DARM勉強会 (構造方程式モデリング)
LDA入門
Rでisomap(多様体学習のはなし)
ファクター投資と機械学習
Rにおける大規模データ解析(第10回TokyoWebMining)
データサイエンス概論第一=3-3 回帰分析
計量経済学と 機械学習の交差点入り口 (公開用)
RでGPU使ってみた
ブートストラップ法とその周辺とR
Tokyo r #37 Rubin's Rule
データサイエンス概論第一=2-1 データ間の距離と類似度
Rで階層ベイズモデル
星野「調査観察データの統計科学」第3章

Similar to {tidygraph}と{ggraph}によるモダンなネットワーク分析 (20)

PDF
Joclad 2010 d
TXT
An example of R code for Data visualization
DOCX
Advanced Data Visualization Examples with R-Part II
PDF
R for you
PPTX
R programming language
DOCX
Advanced Data Visualization in R- Somes Examples.
PDF
data-visualization.pdf
PDF
dplyr use case
PPTX
RBootcamp Day 4
PDF
MH prediction modeling and validation in r (2) classification 190709
PPTX
Introduction to R
PDF
Meetup Analytics with R and Neo4j
PDF
Lois de kirchhoff, dipôles électrocinétiques
PDF
Using a mobile phone as a therapist - Superweek 2018
PDF
Let’s Talk About Ruby
PDF
Download full ebook of Datacamp Ggplot2 Cheatsheet Itebooks instant download pdf
PDF
PDF
PLOTCON NYC: Behind Every Great Plot There's a Great Deal of Wrangling
DOCX
CLUSTERGRAM
DOCX
A Shiny Example-- R
Joclad 2010 d
An example of R code for Data visualization
Advanced Data Visualization Examples with R-Part II
R for you
R programming language
Advanced Data Visualization in R- Somes Examples.
data-visualization.pdf
dplyr use case
RBootcamp Day 4
MH prediction modeling and validation in r (2) classification 190709
Introduction to R
Meetup Analytics with R and Neo4j
Lois de kirchhoff, dipôles électrocinétiques
Using a mobile phone as a therapist - Superweek 2018
Let’s Talk About Ruby
Download full ebook of Datacamp Ggplot2 Cheatsheet Itebooks instant download pdf
PLOTCON NYC: Behind Every Great Plot There's a Great Deal of Wrangling
CLUSTERGRAM
A Shiny Example-- R

More from Takashi Kitano (13)

PDF
好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜
PDF
{shiny}と{leaflet}による地図アプリ開発Tips
PDF
令和から本気出す
PDF
20170923 excelユーザーのためのr入門
PDF
mxnetで頑張る深層学習
PDF
可視化周辺の進化がヤヴァイ 〜2016〜
PDF
Rによるウイスキー分析
PDF
20160311 基礎からのベイズ統計学輪読会第6章 公開ver
PDF
20140625 rでのデータ分析(仮) for_tokyor
PDF
lubridateパッケージ入門
PDF
20150329 tokyo r47
PDF
20140920 tokyo r43
PDF
Google's r style guideのすゝめ
好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜
{shiny}と{leaflet}による地図アプリ開発Tips
令和から本気出す
20170923 excelユーザーのためのr入門
mxnetで頑張る深層学習
可視化周辺の進化がヤヴァイ 〜2016〜
Rによるウイスキー分析
20160311 基礎からのベイズ統計学輪読会第6章 公開ver
20140625 rでのデータ分析(仮) for_tokyor
lubridateパッケージ入門
20150329 tokyo r47
20140920 tokyo r43
Google's r style guideのすゝめ

Recently uploaded (20)

PPTX
1_Introduction to advance data techniques.pptx
PDF
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
PPTX
Introduction to Knowledge Engineering Part 1
PPTX
IBA_Chapter_11_Slides_Final_Accessible.pptx
PPTX
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
PPTX
climate analysis of Dhaka ,Banglades.pptx
PPTX
oil_refinery_comprehensive_20250804084928 (1).pptx
PPTX
Acceptance and paychological effects of mandatory extra coach I classes.pptx
PPTX
Qualitative Qantitative and Mixed Methods.pptx
PPTX
Business Acumen Training GuidePresentation.pptx
PPTX
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
PPTX
Business Ppt On Nestle.pptx huunnnhhgfvu
PPTX
Introduction-to-Cloud-ComputingFinal.pptx
PPT
Quality review (1)_presentation of this 21
PDF
Fluorescence-microscope_Botany_detailed content
PPT
Reliability_Chapter_ presentation 1221.5784
PPTX
IB Computer Science - Internal Assessment.pptx
PDF
Foundation of Data Science unit number two notes
PPTX
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
1_Introduction to advance data techniques.pptx
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
Introduction to Knowledge Engineering Part 1
IBA_Chapter_11_Slides_Final_Accessible.pptx
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
climate analysis of Dhaka ,Banglades.pptx
oil_refinery_comprehensive_20250804084928 (1).pptx
Acceptance and paychological effects of mandatory extra coach I classes.pptx
Qualitative Qantitative and Mixed Methods.pptx
Business Acumen Training GuidePresentation.pptx
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
Business Ppt On Nestle.pptx huunnnhhgfvu
Introduction-to-Cloud-ComputingFinal.pptx
Quality review (1)_presentation of this 21
Fluorescence-microscope_Botany_detailed content
Reliability_Chapter_ presentation 1221.5784
IB Computer Science - Internal Assessment.pptx
Foundation of Data Science unit number two notes
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx

{tidygraph}と{ggraph}によるモダンなネットワーク分析

  • 9. 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 A B B C C E D B E D E F
  • 16. # whiskies <- data.table::fread("http:// outreach.mathstat.strath.ac.uk/outreach/nessie/datasets/ whiskies.txt", header = TRUE) # cor.mat <- whiskies %>% select(Body, Sweetness, Smoky, Medicinal, Tobacco, Honey, Spicy, Winey, Nutty, Malty, Fruity, Floral) %>% t() %>% cor()
  • 17. # colnames(cor.mat) <- whiskies$Distillery rownames(cor.mat) <- whiskies$Distillery # cor.mat[upper.tri(cor.mat, diag = TRUE)] <- NA cor.mat[1:5, 1:5] Aberfeldy Aberlour AnCnoc Ardbeg Ardmore Aberfeldy NA NA NA NA NA Aberlour 0.7086322 NA NA NA NA AnCnoc 0.6973541 0.5030737 NA NA NA Ardbeg -0.1473114 -0.2285909 -0.1404355 NA NA Ardmore 0.7319024 0.5118338 0.5570195 0.2316174 NA
  • 18. # Long-Format 0.8 d <- cor.mat %>% as.data.frame() %>% mutate(distillerry1 = whiskies$Distillery) %>% gather(key = distillerry2, value = cor, -distillerry1) %>% select(distillerry1, distillerry2, cor) %>% filter(!is.na(cor) & cor >= 0.80) head(d) distillerry1 distillerry2 cor 1 Auchroisk Aberfeldy 0.8238415 2 Benrinnes Aberfeldy 0.8419479 3 Benromach Aberfeldy 0.8554217
  • 20. # tbl_graph g <- as_tbl_graph(d, directed = FALSE) g # A tbl_graph: 67 nodes and 135 edges # # An undirected simple graph with 1 component # # Node Data: 67 x 1 (active) name <chr> 1 Auchroisk 2 Benrinnes
  • 21. # tbl_graph g <- as_tbl_graph(d, directed = FALSE) g # A tbl_graph: 67 nodes and 135 edges # # An undirected simple graph with 1 component # # Node Data: 67 x 1 (active) name <chr> 1 Auchroisk 2 Benrinnes
  • 22. 3 Benromach 4 BlairAthol 5 RoyalLochnagar 6 Speyside # ... with 61 more rows # # Edge Data: 135 x 3 from to cor <int> <int> <dbl> 1 1 54 0.824 2 2 54 0.842 3 3 54 0.855 # ... with 132 more rows
  • 23. 3 Benromach 4 BlairAthol 5 RoyalLochnagar 6 Speyside # ... with 61 more rows # # Edge Data: 135 x 3 from to cor <int> <int> <dbl> 1 1 54 0.824 2 2 54 0.842 3 3 54 0.855 # ... with 132 more rows
  • 24. # g %>% igraph::graph.density() [1] 0.06105834 # g %>% igraph::transitivity() [1] 0.2797927 # ( 1) g %>% igraph::reciprocity() [1] 1
  • 25. # g <- g %>% mutate(centrality = centrality_betweenness()) g # A tbl_graph: 67 nodes and 135 edges # # An undirected simple graph with 1 component # # Node Data: 67 x 2 (active) name centrality <chr> <dbl> 1 Auchroisk 174. 2 Benrinnes 122. 3 Benromach 411.
  • 26. # g <- g %E>% mutate(centrality = centrality_edge_betweenness()) g # A tbl_graph: 67 nodes and 135 edges # # An undirected simple graph with 1 component # # Edge Data: 135 x 4 (active) from to cor centrality <int> <int> <dbl> <dbl> 1 1 54 0.824 79.3 2 2 54 0.842 42.9 3 3 54 0.855 54.2
  • 27. # g <- g %E>% mutate(centrality = centrality_edge_betweenness()) g # A tbl_graph: 67 nodes and 135 edges # # An undirected simple graph with 1 component # # Edge Data: 135 x 4 (active) from to cor centrality <int> <int> <dbl> <dbl> 1 1 54 0.824 79.3 2 2 54 0.842 42.9 3 3 54 0.855 54.2
  • 28. # g <- g %>% mutate(community = as.factor(group_fast_greedy(weights = cor))) g # A tbl_graph: 67 nodes and 135 edges # # An undirected simple graph with 1 component # # Node Data: 67 x 2 (active) name community <chr> <fct> 1 Auchroisk 2 2 Benrinnes 3 3 Benromach 2
  • 32. g %>% ggraph(layout = "kk") + geom_edge_link(aes(width = cor), alpha = 0.8, colour = "lightgray")
  • 34. g %>% ggraph(layout = "kk") + geom_edge_link(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1))
  • 36. g %>% ggraph(layout = "kk") + geom_edge_link(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1)) + geom_node_point(aes(colour = community, size = degree))
  • 38. g %>% ggraph(layout = "kk") + geom_edge_link(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1)) + geom_node_point(aes(colour = community, size = degree)) + geom_node_text(aes(label = name), repel = TRUE)
  • 40. g %>% ggraph(layout = "kk") + geom_edge_link(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1)) + geom_node_point(aes(colour = community, size = degree)) + geom_node_text(aes(label = name), repel = TRUE) + theme_graph()
  • 42. g %>% ggraph(layout = "kk") + geom_edge_arc(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1)) + geom_node_point(aes(colour = community, size = degree)) + theme_graph(background = "grey20", text_colour = "white")
  • 45. g %>% mutate(degree = centrality_degree(), community = as.factor(group_fast_greedy(weights = cor))) %>% filter(degree >= 6) %E>% filter(cor > 0.85) %>% ggraph(layout = "lgl") + geom_edge_link(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1)) + geom_node_point(aes(colour = community, size = degree)) + geom_node_text(aes(label = name), repel = TRUE) + theme_graph()
  • 46. g %>% ggraph(layout = "kk") + geom_edge_fan(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1)) + geom_node_point(aes(colour = community, size = degree)) + geom_node_text(aes(label = name), repel = TRUE) + theme_graph()
  • 47. g %>% ggraph(layout = "linear") + geom_edge_arc(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1)) + geom_node_point(aes(colour = community, size = degree)) + geom_node_text(aes(label = name), repel = TRUE) + theme_graph()
  • 49. g %>% ggraph(layout = "linear", circular = TRUE) + geom_edge_arc(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1)) + geom_node_point(aes(colour = community, size = degree)) + geom_node_text(aes(label = name), repel = TRUE) + theme_graph()
  • 51. # d <- whiskies %>% select(Body, Sweetness, Smoky, Medicinal, Tobacco, Honey, Spicy, Winey, Nutty, Malty, Fruity, Floral) %>% dist() # hc <- hclust(d, method="ward.D2") # tbl_graph g <- as_tbl_graph(hc)
  • 52. g %>% ggraph(layout = "kk") + geom_edge_link(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1)) + geom_node_point(aes(colour = community, size = degree)) + geom_node_text(aes(label = name), repel = TRUE) + theme_graph()