Created
May 13, 2018 22:44
-
-
Save sillasgonzaga/4a7cb7135a04c6e7e274680b71fbc643 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(igraph) | |
library(ggraph) | |
library(abjutils) | |
df <- read_rds("data/socios_cvm.rds") | |
glimpse(df) | |
df_clean <- df %>% | |
filter(tipo == "02") %>% | |
mutate(denom_comerc = rm_accent(denom_comerc)) | |
df_grafo <- df_clean %>% | |
select(nome, empresa = denom_comerc) | |
df_grafo <- inner_join(df_grafo, df_grafo, by = "nome") %>% | |
filter(empresa.x != empresa.y) %>% | |
select(empresa.x, empresa.y) %>% | |
na.omit() %>% | |
count(empresa.x, empresa.y, sort = TRUE) | |
df_grafo <- df_grafo %>% | |
rowwise() %>% | |
mutate(concat = paste0(sort(c(empresa.x, empresa.y)), collapse = "_")) %>% | |
ungroup() | |
df_grafo <- df_grafo %>% | |
distinct(concat, .keep_all = TRUE) %>% | |
select(-concat) | |
df_grafo | |
g <- graph_from_data_frame(df_grafo, directed = FALSE) | |
vcount(g) | |
g | |
g %>% | |
ggraph() + | |
geom_node_point() + | |
geom_edge_link(aes(alpha = n)) + | |
theme_graph() + | |
labs(title = "Interseção entre sócios em empresas da CVM") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment