forked from antongrau/soc.sna
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterlocks.R
70 lines (30 loc) · 1.39 KB
/
interlocks.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
######## Analyse af virksomhedernes interlocks
setwd("~/My Dropbox/R/interlocks")
rel <- read.csv("~/My Dropbox/Elite/Data/Data/Relation_BIQ_top.csv", sep="|", encoding="UTF-8")
org <- read.csv("~/My Dropbox/Elite/Data/Data/Organisation_BIQ_top.csv", sep="|", encoding="UTF-8")
source("~/My Dropbox/R/soc.sna/soc.sna.R")
library(ggplot2)
library(cluster)
library(igraph)
netmat <- data.frame(rel$NAVN, rel$ORG_NAVN)
colnames(netmat) <- c("navn", "org")
tabnet <- table(netmat)
tabnet <- as.matrix(tabnet)
adj.org <- t(tabnet)%*%tabnet
diagonal.org <- diag(adj.org)
diag(adj.org) <- 0
net.org <- graph.adjacency(adj.org, weighted=TRUE)
com <- clusters(net.org)
net.component <- net.org - which(which.max(com$csize) != com$membership)
save(net.org, net.component, org, diagonal.org, file="corporate.interlocks")
#### Oprydning
vægt <- E(net.org)$weight
E(net.org)[vægt==4]
sort(rowSums(adj.org == diagonal.org))
adj.div <- adj.org / diagonal.org # Hvor mange procent af deres bestyrelse de deler med en anden virksomhed
subber <- which(adj.div >= 0.5, arr.ind = TRUE)
overlap <- adj.div[subber[,1], subber[,2]]
danger <- data.frame(rownames(overlap), colnames(overlap), round(diag(overlap),2))
danger <- danger[order(danger[,3], decreasing=TRUE),]
colnames(danger) <- c("fra", "til", "med")
write.csv(danger, file="danger.csv")