Veri

sekme = "tweets_escinsel_2018-07-01"
LGBTI_LOVE_DATASET_1 <- read_excel("../LGBTI+_LOVE_DATASET#1.xlsx", sheet = sekme)
text_df <- LGBTI_LOVE_DATASET_1
text_df$baslik  = text_df$tweet
text_df %>% unnest_tokens(word, baslik,token = stringr::str_split, pattern = " ") ->text_word
text_word %>% mutate(node_type=ifelse(str_detect(word,"@"),"user","idea")) -> text_word
text_word %>% mutate(kok = gsub("[[:digit:]]",' ',word)) -> text_word
text_word %>% mutate(kok = gsub("[[:space:]]",' ',kok)) -> text_word
text_word %>% mutate(kok = gsub("^@[[:punct:]]",' ',kok)) -> text_word
text_word %>% mutate(username = paste("@",username,sep="")) -> text_word
text_word
## # A tibble: 86,998 x 19
##    date                time                username name  tweet urls  photos
##    <dttm>              <dttm>              <chr>    <chr> <chr> <chr> <chr> 
##  1 2020-11-26 00:00:00 1899-12-31 03:53:28 @e_efte… DELİ… @umu… []    []    
##  2 2020-11-26 00:00:00 1899-12-31 03:53:28 @e_efte… DELİ… @umu… []    []    
##  3 2020-11-26 00:00:00 1899-12-31 03:53:28 @e_efte… DELİ… @umu… []    []    
##  4 2020-11-26 00:00:00 1899-12-31 03:53:28 @e_efte… DELİ… @umu… []    []    
##  5 2020-11-26 00:00:00 1899-12-31 03:53:28 @e_efte… DELİ… @umu… []    []    
##  6 2020-11-26 00:00:00 1899-12-31 03:53:28 @e_efte… DELİ… @umu… []    []    
##  7 2020-11-26 00:00:00 1899-12-31 03:53:28 @e_efte… DELİ… @umu… []    []    
##  8 2020-11-26 00:00:00 1899-12-31 03:53:28 @e_efte… DELİ… @umu… []    []    
##  9 2020-11-26 00:00:00 1899-12-31 03:53:28 @e_efte… DELİ… @umu… []    []    
## 10 2020-11-26 00:00:00 1899-12-31 03:53:28 @e_efte… DELİ… @umu… []    []    
## # … with 86,988 more rows, and 12 more variables: replies_count <dbl>,
## #   retweets_count <dbl>, likes_count <dbl>, hashtags <chr>, link <chr>,
## #   quote_url <chr>, video <dbl>, thumbnail <chr>, reply_to <chr>, word <chr>,
## #   node_type <chr>, kok <chr>
library(igraph)
text_word %>% select(username,word)  -> nw_df
colnames(nw_df) <-c('source','target')
nw_df %>% filter(str_count(target)>5) %>% filter(str_count(target)>5) -> nw_df

nw_df %>% write.csv(file="network_df.csv")
nw_df
## # A tibble: 50,506 x 2
##    source      target         
##    <chr>       <chr>          
##  1 @e_eftekkin @umuttikir     
##  2 @e_eftekkin düşmanları,    
##  3 @e_eftekkin hayvan         
##  4 @e_eftekkin istismarcıları,
##  5 @e_eftekkin eşcinsel       
##  6 @e_eftekkin sapıklar       
##  7 @e_eftekkin hayatın        
##  8 @e_eftekkin alanında       
##  9 @e_eftekkin mücadele       
## 10 @e_eftekkin toplum         
## # … with 50,496 more rows

Analiz

nw_df %>% graph_from_data_frame() -> g
delete.vertices(g, V(g)[ degree(g) < 90]) -> simple_g
plot(simple_g, 
     vertex.size= 0.01,
     edge.arrow.size=0.001,
     vertex.label.cex = 0.75,
     vertex.label.color = "black"  ,
     vertex.frame.color = adjustcolor("white", alpha.f = 0),
     vertex.color = adjustcolor("white", alpha.f = 0),
     edge.color=adjustcolor(1, alpha.f = 0.15),
     layout=layout.circle(simple_g),
     vertex.label.cex=0.5)

library(visNetwork)
delete.vertices(g, V(g)[ degree(g) < 50]) -> simple_g
V(simple_g)$size <- degree(simple_g) /10
V(simple_g)$color <- c("green", "grey","blue","red","orange","yellow")
## Warning in vattrs[[name]][index] <- value: number of items to replace is not a
## multiple of replacement length
#V(g)$color <- c("green")
visNetwork::visIgraph(simple_g, physics= FALSE)%>% 
  visInteraction(navigationButtons = TRUE) %>% 
   visOptions(selectedBy = "group", 
                highlightNearest = TRUE, 
                nodesIdSelection = TRUE) %>%
                  visPhysics(stabilization = FALSE)
## Warning in visOptions(., selectedBy = "group", highlightNearest = TRUE, : Can't
## find 'group' in node data.frame