트위터 사용자 분석

R로 소셜 미디어 데이터 분석하기

Vivek Vijayaraghavan

Data Science Coach

강의 개요

  • 사용자의 friends_countfollowers_count
  • 브랜드 프로모션을 위한 골든 레이시오 해석
  • 관심 제품 사용자 파악을 위한 트위터 리스트
R로 소셜 미디어 데이터 분석하기

팔로워 vs 친구

트위터 친구와 팔로워

  • Followers: 해당 사용자를 팔로우하는 사용자
  • Friends: 해당 사용자가 팔로우하는 계정
R로 소셜 미디어 데이터 분석하기

트위터 팔로워/팔로잉 비율

골든 레이시오 수식

  • 마케터가 프로모션 전략에 활용
R로 소셜 미디어 데이터 분석하기

양/음의 비율

  • 양의 비율: 팔로워가 친구보다 많음
  • 음의 비율: 친구가 팔로워보다 많음
R로 소셜 미디어 데이터 분석하기

사용자 정보 추출

# Search for 1000 tweets on #fitness
tweet_fit <- search_tweets("#fitness", n = 1000)
# Extract user information
user_fit <- users_data(tweet_fit)
R로 소셜 미디어 데이터 분석하기

사용자 정보 추출

# View column names of the user data
names(user_fit)

사용자 데이터의 열 이름

R로 소셜 미디어 데이터 분석하기

followers_count와 friends_count 추출

  • 사용자 screen_name별 followers, friends 수 집계
# Aggregate screen_name, followers_count & friends_count
library(dplyr)
counts_df <- user_fit %>%
               group_by(screen_name) %>%
               summarize(follower = mean(followers_count),
               friend = mean(friends_count))
R로 소셜 미디어 데이터 분석하기

followers_count와 friends_count 추출

head(counts_df)
screen_name      follower     friend
<chr>              <dbl>       <dbl>
__seokjinnie124     209        454        
_Aminata            623        523        
_amsvn              167        126        
_arweeennn          539        801        
_asof_             1336        455        
_blendac            833        195
R로 소셜 미디어 데이터 분석하기

골든 레이시오

# Create a column to calculate the golden ratio
counts_df$ratio <- follow_df$follower/follow_df$friend
head(counts_df$ratio)
[1] 0.4603524 1.1912046 1.3253968 0.6729089 2.9362637 4.2717949
R로 소셜 미디어 데이터 분석하기

비율 기반 사용자 탐색

  • 골든 레이시오로 사용자 유형 파악
# Sort the data frame in decreasing order of follower count
counts_sort <- arrange(counts_df, desc(follower))
R로 소셜 미디어 데이터 분석하기

비율 기반 사용자 탐색

# Select rows where the follower count is greater than 30000
counts_sort[counts_sort$follower>30000,]
screen_name    follower    friend    ratio        
<chr>            <dbl>      <dbl>    <dbl>
mashable         9817699    2783     3528    
MensHealthMag    4528421    1111     4076    
Sophie_Choudry   2367827    157      15082    
thewebmaster_    103936     6508     16    
qwikad           92932      89557    1    
Rharvley         90464      19484    5    
SayWhenLA        68122      6680     10
  • 피트니스 제품 프로모션 채널로 활용
R로 소셜 미디어 데이터 분석하기

비율 기반 사용자 탐색

# Select rows where the follower count is less than 2000
counts_sort[counts_sort$follower<2000,]
screen_name    follower     friend    ratio        
<chr>            <dbl>       <dbl>    <dbl>
workout_ehime    1960        1027       2    
SardImperium     1932        256        8    
Deem_Hoops       1912        1520       1    
kaykay_inem      1890        443        4    
bhealhty         1855        3066       1
  • 타깃 프로모션을 위해 개인 계정에 광고 집행
R로 소셜 미디어 데이터 분석하기

트위터 리스트로 사용자 분석

  • 트위터 리스트는 선별된 계정 모음입니다
  • 사용자는 관심 리스트를 구독합니다
R로 소셜 미디어 데이터 분석하기

구독 리스트 추출

# Get all lists "Playstation" subscribes to
lst_playstation <- lists_users("PlayStation")
lst_playstation[,1:4]
list_id          name                      uri               subscriber_count
<chr>            <chr>                    <chr>                      <int>
58505230       PS Family         /PlayStation/lists/ps-family         136    
4747423        GameDevelopers    /PlayStation/lists/gamedevelopers    467    
2490894        gaming            /PlayStation/lists/gaming            658
R로 소셜 미디어 데이터 분석하기

리스트 구독자 추출

# Extract 100 subscribers of the "gaming" list owned by "Playstation"
list_PS_sub <- lists_subscribers(slug = "gaming", owner_user = "PlayStation", n = 100)
R로 소셜 미디어 데이터 분석하기

구독자 스크린 네임 보기

# View screen names of the subscribers
list_PS_sub$screen_name

구독자의 스크린 네임

R로 소셜 미디어 데이터 분석하기

리스트 구독자의 사용자 정보

# Create a list of four screen names
users <- c("Morten83032201","ndugumr", "WOLF210_Warrior", "souransb")
# Extract user information
users_PS_gaming <- lookup_users(users)
user_id                   status_id              created_at          screen_name
<chr>                       <chr>               <S3: POSIXct>          <chr>
1158299850573791233    1172604921121824769    2019-09-13 20:16:13    Morten83032201    
894525207620321280     1183293767215992832    2019-10-13 08:09:53    ndugumr    
325760816              1182867378293616640    2019-10-12 03:55:34    WOLF210_Warrior    
469270931              511997829384904704     2014-09-16 21:59:29    souransb
R로 소셜 미디어 데이터 분석하기

연습해 봅시다!

R로 소셜 미디어 데이터 분석하기

Preparing Video For Download...