Video Viral Yusuf Manshur - Social Network Analysis

“Hari ini saya masih berhadapan dengan hukum ini, hukum itu. Apa saya ngadu sama Anda semua? Dan apa Anda membela saya semua? Anda bersuara ke mana-mana. Nggak saya denger juga tuh,” kata Yusuf Mansur dalam video yang dikutip detikcom dari Channel YouTube, Paytren Official, Kamis (24/4/2022). Video viral itu kemudian jadi trending di Twitter.

Kali ini saya akan melakukan Social Network Analysis melalui perbincangan di Twitter mengenai Video Viral Yusuf Manshur, siapa-siapa saja yang menjadi pusat pembicaraannya dan apa yang dibicarakan.

Library dan Setup

Untuk dapat menajalankan analisis ini, berikut ini adalah beberapa packages yang diperlukan sebagai alat bantu:

library(tidyverse)

# graph
library(tidygraph)
library(ggraph)
library(igraph)

Exploratory Data Analysis

Setelah memanggil package yang diperlukan, saya mengambil data dari Twitter API (20 Januari 2022) dengan menggunakan package rtweet di twitter developer dengan screet token dan key. Demi keamanan, codenya tidak saya tampilkan.

Menarik data Twitter dengan keyword tertentu

Data diambil dengan keyword “Yusuf Mansur” pada jumlah tertentu. Kemudian data dari Twitter API tersebut di simpan ke dalam file berformat csv.

ucup <- read.csv("ucup.csv")
glimpse(ucup)
## Rows: 15,200
## Columns: 91
## $ user_id                 <chr> "x1425784901337370626", "x1210156871555772417"…
## $ status_id               <chr> "x1513068505394200581", "x1513068499169849345"…
## $ created_at              <chr> "2022-04-10 08:16:57", "2022-04-10 08:16:56", …
## $ screen_name             <chr> "urboyfiejaehyuN", "noranjae12", "kinandhii", …
## $ text                    <chr> "Nih siapapun yg ngedit videonya Yusuf Mansur,…
## $ source                  <chr> "Twitter for Android", "Twitter for Android", …
## $ display_text_width      <int> 140, 140, 140, 140, 140, 140, 143, 106, 95, 14…
## $ reply_to_status_id      <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ reply_to_user_id        <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ reply_to_screen_name    <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ is_quote                <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALS…
## $ is_retweet              <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE…
## $ favorite_count          <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
## $ retweet_count           <int> 10014, 10014, 10014, 10014, 10014, 10014, 255,…
## $ quote_count             <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ reply_count             <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ hashtags                <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ symbols                 <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ urls_url                <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ urls_t.co               <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ urls_expanded_url       <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ media_url               <chr> "", "", "", "", "", "", "", "", "http://pbs.tw…
## $ media_t.co              <chr> "", "", "", "", "", "", "", "", "https://t.co/…
## $ media_expanded_url      <chr> "", "", "", "", "", "", "", "", "https://twitt…
## $ media_type              <chr> "", "", "", "", "", "", "", "", "photo", "", "…
## $ ext_media_url           <chr> "", "", "", "", "", "", "", "", "http://pbs.tw…
## $ ext_media_t.co          <chr> "", "", "", "", "", "", "", "", "https://t.co/…
## $ ext_media_expanded_url  <chr> "", "", "", "", "", "", "", "", "https://twitt…
## $ ext_media_type          <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ mentions_user_id        <chr> "x1358396047643471873", "x1358396047643471873"…
## $ mentions_screen_name    <chr> "TwinkleHan13", "TwinkleHan13", "TwinkleHan13"…
## $ lang                    <chr> "in", "in", "in", "in", "in", "in", "in", "in"…
## $ quoted_status_id        <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ quoted_text             <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ quoted_created_at       <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ quoted_source           <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ quoted_favorite_count   <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ quoted_retweet_count    <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ quoted_user_id          <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ quoted_screen_name      <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ quoted_name             <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ quoted_followers_count  <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ quoted_friends_count    <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ quoted_statuses_count   <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ quoted_location         <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ quoted_description      <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ quoted_verified         <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ retweet_status_id       <chr> "x1512581215139762176", "x1512581215139762176"…
## $ retweet_text            <chr> "Nih siapapun yg ngedit videonya Yusuf Mansur,…
## $ retweet_created_at      <chr> "2022-04-09 00:00:38", "2022-04-09 00:00:38", …
## $ retweet_source          <chr> "Twitter for Android", "Twitter for Android", …
## $ retweet_favorite_count  <int> 35347, 35347, 35347, 35347, 35347, 35347, 1602…
## $ retweet_retweet_count   <int> 10014, 10014, 10014, 10014, 10014, 10014, 255,…
## $ retweet_user_id         <chr> "x1358396047643471873", "x1358396047643471873"…
## $ retweet_screen_name     <chr> "TwinkleHan13", "TwinkleHan13", "TwinkleHan13"…
## $ retweet_name            <chr> "HanHan", "HanHan", "HanHan", "HanHan", "HanHa…
## $ retweet_followers_count <int> 185, 185, 185, 185, 185, 185, 30898, 73, 1085,…
## $ retweet_friends_count   <int> 109, 109, 109, 109, 109, 109, 3151, 64, 666, 1…
## $ retweet_statuses_count  <int> 270, 270, 270, 270, 270, 270, 161917, 858, 298…
## $ retweet_location        <chr> "", "", "", "", "", "", "Di hati para Kafirist…
## $ retweet_description     <chr> "Just a person who loves Jimin, Bangtan and Ji…
## $ retweet_verified        <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALS…
## $ place_url               <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ place_name              <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ place_full_name         <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ place_type              <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ country                 <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ country_code            <chr> "", "", "", "", "", "", "", "", "", "", "", ""…
## $ geo_coords              <chr> "NA NA", "NA NA", "NA NA", "NA NA", "NA NA", "…
## $ coords_coords           <chr> "NA NA", "NA NA", "NA NA", "NA NA", "NA NA", "…
## $ bbox_coords             <chr> "NA NA NA NA NA NA NA NA", "NA NA NA NA NA NA …
## $ status_url              <chr> "https://twitter.com/urboyfiejaehyuN/status/15…
## $ name                    <chr> "N", "ælyn ୧⍤⃝🥠", "inan", "jah : jual template…
## $ location                <chr> "jakarta, Indonesia", "East Java, Indonesia", …
## $ description             <chr> "she/her\n\njaehyun addict 🤯", "💚🍑\nmanycit…
## $ url                     <chr> "", "", "", "https://t.co/SM9B6kCh4m", "", "ht…
## $ protected               <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALS…
## $ followers_count         <int> 4, 29, 111, 605, 1, 122, 729, 729, 729, 61, 10…
## $ friends_count           <int> 92, 143, 263, 614, 98, 105, 442, 442, 442, 91,…
## $ listed_count            <int> 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 11, 2, 1, …
## $ statuses_count          <int> 895, 4959, 1748, 3110, 524, 5986, 189020, 1890…
## $ favourites_count        <int> 12485, 2303, 22970, 3864, 705, 10333, 112232, …
## $ account_created_at      <chr> "2021-08-12 11:43:26", "2019-12-26 11:14:25", …
## $ verified                <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALS…
## $ profile_url             <chr> "", "", "", "https://t.co/SM9B6kCh4m", "", "ht…
## $ profile_expanded_url    <chr> "", "", "", "http://wa.me/+6289524000804", "",…
## $ account_lang            <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ profile_banner_url      <chr> "https://pbs.twimg.com/profile_banners/1425784…
## $ profile_background_url  <chr> "", "", "", "", "", "", "http://abs.twimg.com/…
## $ profile_image_url       <chr> "http://pbs.twimg.com/profile_images/150256113…
## $ query                   <chr> "Yusuf Mansur", "Yusuf Mansur", "Yusuf Mansur"…

Dari data yang ditarik (10 April 2022) cuma didapat 15200 tweets yang mengandung keyword “Yusuf Mansur”.

head(ucup)

Dari data, dapat diketahui bahwa melalui kolom is_retweet kita dapat melakukan filter mana yang retweet mana yang bukan, kemudian menghitung jumlah baris dari semua data yang retweet saja dengan syntax berikut:

ucup %>% 
  filter(is_retweet == TRUE) %>% 
  do(data.frame(retweet_count=nrow(.)))

Dapat diketahui bahwa ada 13,941 retweet.

Kemudian dapat diketahui juga akun (screen_name) dengan jumlah retweet terbanyak dengan syntax berikut:

ucup %>% 
   filter(retweet_count == max(retweet_count)) %>% 
   select(screen_name, retweet_count,created_at)

Dapat diketahui bahwa ada 144 akun yang jumlah retweetnya sama. Ini suatu anomali, apakah ini mungkin yang disebut akun bot?

Data cleansing

Mengambil kolom screen_name, dan mentions_screen_name

ucup %>% 
  select(screen_name,mentions_screen_name)

Membuat Edges

edge_ucup <-
ucup %>% 
  select(screen_name,mentions_screen_name) %>% 
  mutate(mentions_screen_name = as.character(mentions_screen_name),
         mentions_screen_name = str_replace_all(string =mentions_screen_name,
                                               pattern = "^c\\(|\\)$", 
                                               replacement = "")) %>%
  separate_rows(mentions_screen_name, sep = ",") %>%
  na.omit() %>% 
  mutate(mentions_screen_name = str_replace_all(string =mentions_screen_name,
                                                pattern =  "[[:punct:] ]+",
                                                replacement = "")) %>% 
  rename(from = screen_name,
         to = mentions_screen_name)
head(edge_ucup)

Membuat Nodes

nodes_ucup <- data.frame(name = unique(c(edge_ucup$from,edge_ucup$to)))

tail(nodes_ucup)

Membuat graph

ucup_tweets <- tbl_graph(nodes = nodes_ucup, 
                       edges = edge_ucup,
                       directed = F)

Centrality Measurement

ucup_tweets <- ucup_tweets %>% 
  activate(nodes) %>%
  mutate(degree = centrality_degree(), 
         between = centrality_betweenness(normalized = T), 
         closeness = centrality_closeness(),
         eigen = centrality_eigen())  
network_act_ucup <- ucup_tweets %>% 
  activate(nodes) %>% 
  as.data.frame()

head(network_act_ucup)

untuk mengetahui user name yang memiliki nilai tertinggi untuk masing-masing ukuran centrality kita dapat mengubahnya menjadi format dibawah.

network_act_ucup %>% 
  arrange(-eigen) %>% 
  select(name) %>% 
  slice(1:6)
ucup_activity <- data.frame(
  network_act_ucup %>% arrange(-degree) %>% select(name) %>% slice(1:6),
  network_act_ucup %>% arrange(-between) %>% select(name) %>% slice(1:6),
  network_act_ucup %>% arrange(-closeness) %>% select(name) %>% slice(1:6),
  network_act_ucup %>% arrange(-eigen) %>% select(name) %>% slice(1:6)
) %>% setNames(c("degree","betweenness","closeness","eigen"))
ucup_activity

Dari data diatas kita bisa melihat bahwa akun TwinkleHan13 merupakan akun dengan degree, betweeneess, closeness dan eigen tertinggi.

ucup %>% 
  filter(mentions_screen_name == "TwinkleHan13") %>% 
  arrange(desc(retweet_count)) %>% 
  distinct(text) %>%  
  pull(text)
## [1] "Nih siapapun yg ngedit videonya Yusuf Mansur, terimakasih banyak, saya bisa ketawa ngakak pagi ini 😭😭😭 https://t.co/jWBuZX31Aw"
## [2] "@TwinkleHan13 Yusuf Mansur versi cover metalnya maszehhh 🤘🏻🕺 https://t.co/Pwv8jq3AOT"                                          
## [3] "@TwinkleHan13 Ada yg punya video original yusuf mansur nya ga?"                                                                   
## [4] "@TwinkleHan13 Om Dedy Corbuzier kok belum ngundang Yusuf Mansur di podcastnya? Aku yang ga update apa bijimane?"

Graph Visualization

Membuat cluster

set.seed(123)
ucup_tweets <- ucup_tweets %>% 
  activate(nodes) %>% 
  mutate(community = group_louvain()) %>% 
  activate(edges) %>% 
  filter(!edge_is_loop())
ucup_tweets %>% 
  activate(nodes) %>% 
  as.data.frame() %>% 
  count(community)

Mendapatkan orang-orang penting di tiap cluster

# fungsi untuk mendapatkan orang orang penting di tiap cluster
imp_user <- function(data) {
  name_person <- data %>%
  as.data.frame() %>% 
  filter(community %in% 1:4) %>% 
  select(-community) %>% 
  pivot_longer(-name, names_to = "measures", values_to = "values") %>% 
  group_by(measures) %>% 
  arrange(desc(values)) %>% 
  slice(1:6) %>% 
  ungroup() %>% 
  distinct(name) %>% 
  pull(name)
  
  return(name_person)
}
penting_person <- 
ucup_tweets %>% 
  activate(nodes) %>% 
  imp_user()


penting_person
##  [1] "TwinkleHan13"                       "AndisBrighter"                     
##  [3] "MAJALAHGATRA"                       "jvdasiskariotYusufMansur"          
##  [5] "BuronanMabesYusufMansurjokowi"      "Nigellasativa5"                    
##  [7] "Bon14194030"                        "AJazuli5"                          
##  [9] "irwns2"                             "revanprtm"                         
## [11] "farkhanfahriza"                     "juhaiman15jvdasiskariotYusufMansur"
## [13] "_FAWS_"

Data Graph Berdasarkan Nilai Degree Centrality

Degree centrality merupakan ukuran pemusatan yang menghitung banyaknya edges yang terhubung ke suatu node. Degree centrality dapat memberitahu seberapa banyak hubungan langsung yang dimiliki setiap node sehingga ketika kita ingin mencari individu yang memiliki koneksi langsung terbanyak dengan orang lain (orang paling populer) kita bisa melihat metrics ini.

Sebaran komunitas

set.seed(13)
ucup_tweets %>%
  activate(nodes) %>%
  mutate(ids = row_number(),
         community = as.character(community)) %>%
  filter(community %in% 1:4) %>%    # ubah berdasarkan jumlah cluster yang ingin di analisa 1:berapa?
  arrange(community,ids) %>%
  mutate(node_label = ifelse(name %in% penting_person, name,NA)) %>%
  ggraph(layout = "fr") +
  geom_edge_link(alpha = 0.08 ) +
  geom_node_point(aes(size = degree, fill = community), shape = 21, alpha = 8, color = "grey30") +
  geom_node_label(aes(label = node_label), repel = T, alpha = 1, color = "black" ) +
  guides(size = "none") +
  labs(title = "Top Community of Trending Yusuf Mansur", # judul plot
       color = "Interaction",
       fill = "Community") + # legend warna
  theme_void() +
  theme(legend.position = "top")

Dari filter 4 komunitas (warna merah, hijau, biru, dan ungu) dia atas dapat diketahui ada 1 besaran sebaran terbesar yaitu komunitas berwarna merah, yang ditengahnya terdapat akun TwinkleHan13 sebagai sumber utama dari pembicaraan tentang Yusuf Mansur ini.

Kemudian ada komunitas berwarna hijau dengan akun AndisBrighter sebagai pusatnya. Berikut ini postingan Twitter AndisBrighter yang paling banyak diretweet oleh netizen.

ucup %>% 
  filter(mentions_screen_name == "AndisBrighter") %>% 
  arrange(desc(retweet_count)) %>% 
  distinct(text) %>%  
  pull(text)
## [1] "Interview Kerja Yusuf Mansur\n(Yang pertama kepotong) https://t.co/gmfO6FikJU"
## [2] "Interview Yusuf Mansur https://t.co/V4GPhsUC44"

Kemudian jika dicek kembali ke grafik sebaran tersebut, ada dua kelompok lain yang cukup tersebar (biru dan ungu). Di komunitas berwarna ungu ada akun jvdasiskariotYusufMansur yang nilai betwenness-nya cukup tinggi. Kemudian ada akun MAJALAHGATRA yang juga memiliki nilai betwenness dan degree cukup tinggi di komunitas berwarna biru.

Sebaran komunitas populer

Untuk lebih jelas, berikut ini filter 2 komunitas terpopuler dari pembicaraan mengenai Yusuf Mansur.

set.seed(13)
ucup_tweets %>%
  activate(nodes) %>%
  mutate(ids = row_number(),
         community = as.character(community)) %>%
  filter(community %in% 1:2) %>%    # ubah berdasarkan jumlah cluster yang ingin di analisa 1:berapa?
  arrange(community,ids) %>%
  mutate(node_label = ifelse(name %in% penting_person, name,NA)) %>%
  ggraph(layout = "fr") +
  geom_edge_link(alpha = 0.08 ) +
  geom_node_point(aes(size = degree, fill = community), shape = 21, alpha = 8, color = "grey30") +
  geom_node_label(aes(label = node_label), repel = T, alpha = 1, color = "black" ) +
  guides(size = "none") +
  labs(title = "Top Community of Trending Yusuf Mansur", # judul plot
       color = "Interaction",
       fill = "Community") + # legend warna
  theme_void() +
  theme(legend.position = "top")