RStudioのmanipulate関数でグラフ描画にインタラクティブな操作を追加する(5)
![イメージ 1](https://cdn-ak.f.st-hatena.com/images/fotolife/s/snatool/20190824/20190824133703.jpg)
#Krackhardt's High-tech managers
#Krackhardt, David ,1987,"Cognitive Social Structures." Social Networks, 9: 109-134.
#Vladimir Batagelj and Andrej Mrvar, 2006, Pajek datasets.
#URL: http://vlado.fmf.uni-lj.si/pub/networks/data/
ADVICE <- matrix(c(
0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,1,
0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,1,0,1,0,1,1,1,1,1,1,1,0,1,0,0,1,1,0,1,1,
1,1,0,0,0,1,0,1,0,1,1,1,0,0,0,1,1,1,0,1,1,
1,1,0,0,0,1,1,1,0,1,1,0,1,1,0,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
0,1,0,0,0,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,
0,1,0,1,0,1,1,0,0,1,1,0,0,0,0,0,0,1,0,0,1,
1,1,0,0,0,1,1,1,0,1,1,1,0,1,0,1,1,1,0,0,1,
1,1,1,1,1,0,0,1,0,0,1,0,1,0,1,1,1,1,1,1,0,
1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,1,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,
0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,
1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,
1,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,0,0,1,1,1,
1,1,1,0,1,0,1,0,0,1,1,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REPORT
library(sna)
library(manipulate)
graph.names <- c("ADVICE", "FRIEND", "REPORT")
coordinates <- gplot(REPORT, jitter = FALSE)
manipulate(
gplot(dat, g = graph, main = graph.names[graph], coord = coordinates, displaylabels = TRUE,
label.pos = 5, vertex.cex = 3, vertex.col = "white", vertex.side = 20, ),
graph = picker("ADVICE" = 1, "FRIEND" = 2, "REPORT" = 3))