Skip to content

Instantly share code, notes, and snippets.

@sillasgonzaga
Created May 13, 2018 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sillasgonzaga/4a7cb7135a04c6e7e274680b71fbc643 to your computer and use it in GitHub Desktop.
Save sillasgonzaga/4a7cb7135a04c6e7e274680b71fbc643 to your computer and use it in GitHub Desktop.
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