Project Specification COMP7025 Social Media Intelligence Aim The Project requires us to analyse social media data using the knowledge obtained from this unit with assistance from a computer based statistical package. For this project, we will focus on Twitter. Method To complete this project: 1. Read through this specification 2. Complete the data analysis required by the specification 3. Write up your analysis using your favourite word processing/typesetting program, making sure that all of the working is shown and that is it presented well. 4. Include the student declaration text on the front page of your report. Please make sure that your name and student number are clearly displayed on the front page. 5. Submit the report as a PDF by the due date. Report Format Once the required analysis is performed, write up the analysis as a report. Remember that the assessor will only see the report and will be marking the analysis based on your report. Therefore the report should contain a clear and concise description of the procedures carried out, the analysis of results, and any conclusions reached from the analysis. The required analysis in this specification covers material presented in lectures and labs. Students should use the computer software R to carry out the required analysis and then present the results from the analysis in the report. 1 Marks This project is worth 30 % of your final grade, and so the project will be marked out of 30. The project consists of six parts where each part contributes equally to your final mark. There are five parts to the project, each will be marked using the following criteria: MarksCriteria Satisfied 0 The method does not lead to insightful analysis. 1 The method is flawed, but the analysis would have provided insight had the method been correct. 2 The correct method leads to partially correct results and analysis. 3 The correct method leads to correct results and analysis. 4 The correct method leads to correct results and analysis, with an insightful aim and conclusion. 5 The correct method leads to correct results and analysis, with an insightful aim and conclusion. Limitations of the analysis are identified and suggestions for further analysis are provided. If a report is submitted late, the maximum mark it can achieve will be reduced by 10% (3 marks) per day. E.g., if a report is submitted five days late, it can receive at most 15 marks. Declaration The following declaration must be included in a clearly visible and readable place on the first page of the report. By including this statement, I the author of this work, verify that: · I hold a copy of this assignment that I can produce if the original is lost or damaged. · I hereby certify that no part of this assignment/product has been copied from any other student’s work or from any other source except where due acknowledgement is made in the assignment. · No part of this assignment/product has been written/produced for us by another person except where such collaboration has been authorised by the subject lecturer/tutor concerned. · I am aware that this work may be reproduced and submitted to plagiarism detection software programs for the purpose of detecting possible plagiarism (which may retain a copy on its database for future plagiarism checking). · I hereby certify that I have read and understand what the School of Computing and Mathematics defines as minor and substantial breaches of misconduct as outlined in the learning guide for this unit. Note: An examiner or lecturer/tutor has the right not to mark this project report if the above declaration has not been added to the cover of the report. Project Description A social and behavioural research group at Western Sydney University is studying social activists. They have consulted you to investigate the flow of information regarding environmental activist Greta Thunberg on Twit- ter. Researchers have provided a set of tasks below that need completion. The results are to be presented at the International Social and Behaviour Change Communication (SBCC) Summit. Perform this analysis using R with the rtweet and igraph libraries. Use the rtweet documentation to find functions that will assist your analysis: · https://cran.r-project.org/web/packages/rtweet/vignettes/intro.html · https://cran.r-project.org/web/packages/rtweet/rtweet.pdf 1 Followed by Greta Find 12 people followed by Greta that have the most followers. Use only people, not any company’s twitter handles. Examine the twitter accounts and summarise the types of people. 2 Followers of Greta Find the 12 people who follow Greta and have the most followers and examine if they have a positive or negative relationship with Greta based on their tweets. Examine their twitter accounts and summarise the types of people. 3 Bypassing Greta Plot the graph containing people followed by Greta and 12 followers. Identify if any of the found following or followers are friends with each other and add these edges to the graph. Then determine if any of the following and followers should be friends, based on their background, and add those edges to the graph. 4 Graph Statistics Compute the diameter and density of the graph, and neighbourhood overlap of each edge and determine which nodes have the greatest social capital. State if the results are obvious from the graph structure and why. 5 Graph Homophily Compute if there is homophily in the graph. To do this, label each node as either a supporter or non-supporter of Greta using the information gathered in parts 1, 2 and 3. Write out the hypotheses, the test statistic and a conclusions of the test. Use a significance level of α = 0.05. 6 Structural Balance Finally, determine if the signed network is weakly balanced (using hierarchical clustering) and identify if any within or between signed relationships are not as expected. To perform this analysis, first label all existing edges as either positive or negative, based on their association to Greta. Write up a report containing your code and analysis of the data with each section clearly labelled. Clearly annotate your code and make sure to state any conclusions you make from each piece of analysis. The report is being marked using the marking criteria, so make sure that each piece of analysis covers all of the criteria. Remember that you are examining the relationship of twitter users to Greta, so make sure that the conclusion of each section refers back to this. ##ASSIGNMENT SOCIAL MEDIA INTELLIGENCE COMP7025 ##STUDENT_NAME : SUHAS THOTA ##STUDENT_ID : 19914060 version install.packages("rtweet") install.packages("base64enc") install.packages("httpuv") install.packages("rtweet") install.packages("dplyr") install.packages("tidytext") install.packages("tidyr") install.packages("textdata") library("rtweet") library("base64enc") library("httpuv") library("magrittr") library("dplyr") library("textdata") #app="1657696929873301504suhasthota1" #api_key="1ag4NiBTizl4S5vRf40jsYFhH" #api_secret_key="kNPoy4r1spzb7ZaZaB7RoDjrTWucPHxiDdjZDDEDjwGgYR3v9f" #acc_token="2278893654-YcpXyvRhjzdELJwDxUWPBXwYkwgEME6u2afVMbc" #acc_secret_token="4Yutcn8OaSvn6i7xPEZaVTqurWKmeRzVcWH7Vv6pH184t" ### Using the above keys resulted in an API error [403] from Twitter; to avoid this, ##I used the keys supplied in the 6a solutions. Twitterkeys.txt #Authenticating with Twitter API Credentials app='SMIProject_2023' api_key='AagjVq96hOMojkDdc0fz8OJPI' api_secret_key='DWrqQZWe2QDabVKDT5nVped8jqDk6UrPGAmJM74xX1xMIVL6Cf' acc_token='124194957-1fvDtoNyoah7sq92QWFZ8GGsAkmmSl1xWBSgb3E3' acc_secret_token='N29dRKpzRSgt7vCcVj8AFCuwfHUROGStK15X7HMeBWvg4' #generate token create_token( app=app, consumer_key=api_key, consumer_secret=api_secret_key, access_token=acc_token, access_secret=acc_secret_token ) #Retrieving tweets tweets=search_tweets("Greta Thunberg",n=5,include_rts=FALSE) print(tweets) ##################################################################################################################################################################################################### #######################Q1.)Followed by Greta Thunberg ############################################################################################################################################### ##################################################################################################################################################################################################### # Get Greta Thunberg's friends (people followed by Greta) friends_data <- get_friends("gretathunberg",="" n="1000)" #="" extract="" the="" user="" ids="" of="" the="" friends="" friend_ids=""><- friends_data$to_id="" #="" fetch="" complete="" user="" information="" for="" the="" friends="" full_friends_data=""><- lookup_users(user="friend_ids)" #="" filter="" out="" company="" accounts="" based="" on="" user="" description="" filtered_friends=""><- full_friends_data[!grepl("^[a-za-z0-9_]{1,15}$",="" tolower(full_friends_data$description)),="" ]="" ##using="" a="" regular="" expression="" pattern,="" the="" code="" above="" attempts="" to="" filter="" out="" twitter="" accounts="" based="" on="" their="" user="" description.="" ##however,="" the="" pattern="" we="" specified,="" "[a-za-z0-9_]1,15$",="" matches="" sequences="" with="" 1="" to="" 15="" alphabetic="" or="" underscore="" characters.="" ##this="" pattern="" is="" ineffective="" at="" filtering="" out="" company="" accounts="" and="" does="" not="" provide="" meaningful="" results.="" filtered_friends=""><- full_friends_data[!grepl("company|corporation|organization",="" tolower(full_friends_data$description)),="" ]="" #we="" can="" employ="" a="" different="" strategy="" to="" exclude="" corporation="" accounts="" based="" on="" their="" user="" description="" from="" the="" full_friends_data="" dataframe.="" #this="" code="" searches="" the="" lowercase="" version="" of="" the="" user="" descriptions="" for="" the="" words="" "company,"="" "corporation,"="" or="" "organization"="" using="" the="" grepl()="" function="" and="" a="" regular="" expression="" pattern.="" #the="" negation="" of="" the="" pattern="" by="" the!="" before="" grepl()="" eliminates="" the="" rows="" in="" which="" the="" pattern="" matches.="" #the="" subset="" of="" individuals="" in="" the="" filtered_friends="" dataframe="" who="" are="" not="" corporation="" accounts="" according="" to="" their="" user="" descriptions="" will="" be="" present="" after="" applying="" this="" filter.="" #after="" then,="" we="" can="" continue="" with="" our="" investigation="" or="" research="" of="" these="" users.="" #="" sort="" filtered="" friends="" by="" follower="" count="" in="" descending="" order="" sorted_friends=""><- filtered_friends[order(-filtered_friends$followers_count),="" ]="" #="" select="" the="" top="" 12="" friends="" with="" the="" most="" followers="" top_friends=""><- head(sorted_friends,="" 12)="" #="" summarize="" the="" types="" of="" people="" summary(top_friends$description)="" top_friends$description="" filtered_top_friends=""><- top_friends[complete.cases(top_friends$name,="" top_friends$location,="" top_friends$screen_name,="" top_friends$description),="" ]="" ##group="" the="" desired="" columns="" and="" summarise="" type="" of="" friends="" summary_friends=""><- filtered_top_friends="" %="">% group_by(name, location, screen_name, description) %>% summarize(Count = n()) %>% ungroup() print(summary_friends) ################################################################################################################################################################ ################################ Q2.) Greta Thunberg Followers ################################################################################################# ################################################################################################################################################################ library(tidytext) #Loads the tidytext package, which provides functions for text mining and analysis. library(dplyr) # Loads the dplyr package, which provides tools for data manipulation and transformation. library(tidyr) #Loads the tidyr package, which provides functions for data tidying and reshaping. #list of Greta Thunberg's followers follower_ids <- get_followers("gretathunberg",="" n="100)" #="" retrieves="" the="" ids="" of="" greta="" thunberg's="" followers="" by="" using="" the="" get_followers="" function="" from="" the="" rtweet="" package.="" it="" retrieves="" 100="" follower="" ids.="" #get="" the="" follower's="" profiles="" and="" sort="" them="" by="" the="" number="" of="" followers:="" follower_profiles=""><- lookup_users(user="follower_ids$from_id)" #retrieves="" the="" profile="" information="" of="" greta="" thunberg's="" followers="" using="" the="" lookup_users="" function="" from="" the="" rtweet="" package.="" #it="" takes="" the="" follower="" ids="" as="" input="" and="" returns="" their="" profiles.="" sorted_profiles=""><- follower_profiles[order(follower_profiles$followers_count,="" decreasing="TRUE)," ]="" #sorts="" the="" follower="" profiles="" based="" on="" the="" number="" of="" followers="" in="" descending="" order,="" using="" the="" order="" function.="" #the="" profiles="" with="" the="" highest="" number="" of="" followers="" will="" be="" at="" the="" top.="" top_followers=""><- head(sorted_profiles,="" 12)="" #selects="" the="" top="" 12="" followers="" from="" the="" sorted="" profiles="" using="" the="" head="" function.="" #these="" are="" the="" followers="" with="" the="" highest="" number="" of="" followers="" themselves.="" view(top_followers)="" #examine="" their="" relationship="" with="" greta="" thunberg="" based="" on="" their="" tweets:="" follower_tweets=""><- get_timeline(user="top_followers$id_str," n="100)" #retrieves="" the="" timeline="" tweets="" of="" the="" top="" followers="" by="" using="" the="" get_timeline="" function="" from="" the="" rtweet="" package.="" #it="" takes="" the="" user="" ids="" of="" the="" top="" followers="" as="" input="" and="" retrieves="" 100="" tweets="" from="" each="" follower.="" view(follower_tweets)="" colnames(follower_tweets)="" follower_sentiments=""><- follower_tweets="" %="">% select(in_reply_to_screen_name,text)%>% unnest_tokens(word, text) %>% inner_join(get_sentiments("bing")) %>% count(in_reply_to_screen_name, sentiment) %>% spread(sentiment, n, fill = 0) View(follower_sentiments) #Performs sentiment analysis on the follower tweets. It selects the relevant columns #(in_reply_to_screen_name and text), tokenizes the text using unnest_tokens, joins the sentiment lexicon using inner_join and #calculates the count of each sentiment for each follower. #Finally, it spreads the sentiment counts into separate columns using spread. summary_followers_1 <- data.frame(="" name="table(top_followers$name)," location="table(top_followers$location)," screenname="table(top_followers$screen_name)," description="table(top_followers$description)," stringsasfactors="FALSE" )="" #creates="" a="" data="" frame="" called="" summary_followers_1="" with="" columns="" for="" name,="" location,="" screenname,="" and="" description.="" #it="" uses="" the="" table="" function="" to="" count="" the="" occurrences="" of="" each="" value="" in="" the="" respective="" columns="" of="" the="" top_followers="" dataset.="" summary_followers_2=""><- subset(summary_followers_1,="" select="-c(Name.Freq," location.freq,="" screenname.freq,="" description.freq))="" #creates="" a="" subset="" of="" summary_followers_1="" called="" summary_followers_2,="" excluding="" the="" columns="" with="" #frequency="" counts="" (name.freq,="" location.freq,="" screenname.freq,="" description.freq).="" view(summary_followers_2)="" #########################################################################################################################################="" ###############################################="" q3.)="" bypassing="" greta="" #####################################################################="" #########################################################################################################################################="" #######################################################################################################="" #="" retrieve="" the="" user="" ids="" of="" greta's="" followers="" and="" the="" people="" she="" follows="" follower_ids=""><- get_followers("gretathunberg",="" n="1000)$from_id" following_ids=""><- get_friends("gretathunberg",="" n="1000)$to_id" #="" get="" the="" profiles="" of="" greta's="" followers="" and="" the="" people="" she="" follows="" follower_profiles=""><- lookup_users(user="follower_ids)" following_profiles=""><- lookup_users(user="following_ids)" #="" extract="" the="" screen="" names="" of="" the="" followers="" and="" the="" people="" greta="" follows="" follower_screen_names=""><- follower_profiles$screen_name="" following_screen_names=""><- following_profiles$screen_name="" #="" find="" common="" screen="" names="" between="" followers="" and="" following="" common_screen_names=""><- intersect(follower_screen_names,="" following_screen_names)="" ###="" there="" are="" no="" common="" friends="" between="" people="" following="" greta="" and="" people="" whom="" greta="" is="" following,="" ###="" for="" a="" border="" perscpective="" to="" see="" if="" there="" are="" any="" indirect="" connections="" or="" shared="" interests="" among="" them,="" we="" are="" investigating="" further="" considering="" factors="" like="" shared="" locations,="" similar="" interests="" or="" common="" affiliations="" ##="" #="" retrieve="" the="" user="" ids="" of="" greta's="" followers="" and="" the="" people="" she="" follows="" follower_ids=""><- get_followers("gretathunberg",="" n="1000)$from_id" following_ids=""><- get_friends("gretathunberg",="" n="1000)$to_id" #="" get="" the="" profiles="" of="" greta's="" followers="" and="" the="" people="" she="" follows="" follower_profiles=""><- lookup_users(user="follower_ids)" following_profiles=""><- lookup_users(user="following_ids)" #="" extract="" the="" screen="" names="" and="" locations="" of="" the="" followers="" and="" the="" people="" greta="" follows="" follower_screen_names=""><- follower_profiles$screen_name="" follower_locations=""><- follower_profiles$location="" following_screen_names=""><- following_profiles$screen_name="" following_locations=""><- following_profiles$location="" #="" find="" common="" locations="" between="" followers="" and="" following="" common_locations=""><- intersect(follower_locations,="" following_locations)="" #="" filter="" profiles="" based="" on="" common="" locations="" follower_profiles_common=""><- follower_profiles[follower_locations="" %in%="" common_locations,="" ]="" following_profiles_common=""><- following_profiles[following_locations="" %in%="" common_locations,="" ]="" #="" identify="" connections="" between="" followers="" follower_friends=""><- get_friends(users="follower_profiles_common$id_str," n="250)" follower_friends_common=""><- follower_friends[follower_friends$to_id="" %in%="" follower_profiles_common$id_str,="" ]="" #="" identify="" connections="" between="" following="" following_friends=""><- get_friends(users="following_profiles_common$user_id," n="250)" #="" add="" edges="" to="" the="" graph="" for="" followers="" and="" following="" connections="" edges_followers=""><- c(rep(1,="" length(follower_friends_common)),="" match(follower_friends_common$to_id,="" follower_profiles_common$id_str))="" edges_following=""><- c(match(following_friends$from_id,="" following_profiles_common$user_id),="" rep(1,="" length(following_friends)))="" edges=""><- c(edges_followers,="" edges_following)="" #="" create="" an="" empty="" graph="" graph=""><- graph.empty()="" #="" add="" vertices="" for="" greta,="" followers,="" and="" following="" vertex_names=""><- c("greta="" thunberg",="" follower_profiles_common$screen_name,="" following_profiles_common$screen_name)="" graph=""><- add_vertices(graph,="" nv="length(vertex_names)," name="vertex_names)" #="" add="" edges="" to="" the="" graph="" graph=""><- add_edges(graph, edges, directed = false) # determine if any of the followers and following should be friends based on their background # you can add logic here based on your criteria for determining friendship # print the graph print(graph) 1 ##assignment social media intelligence comp7025 ##student_name : suhas thota ##student_id : add_edges(graph,="" edges,="" directed="FALSE)" #="" determine="" if="" any="" of="" the="" followers="" and="" following="" should="" be="" friends="" based="" on="" their="" background="" #="" you="" can="" add="" logic="" here="" based="" on="" your="" criteria="" for="" determining="" friendship="" #="" print="" the="" graph="" print(graph)="" 1="" ##assignment="" social="" media="" intelligence="" comp7025="" ##student_name="" :="" suhas="" thota="" ##student_id="">
Answered 2 days AfterJun 08, 2023

Answer To:

Pratibha answered on Jun 10 2023
24 Votes
Text scraping and Analysis
Text scraping and Analysis
2023-06-10
API Setup
library("rtweet")
## Warning: package 'rtweet' was built under R version 4.2.3
library("base64enc")
library("httpuv")
## Warning: package 'httpuv' was built under R version 4.2.3
library("magrittr")
library("dplyr")
## Warning: package 'dplyr' was built under R version 4.2.3
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library("textdata")
## Warning: package 'textdata' was built under R version 4.2.3
#Authenticating with Twitter API Credentials
app='GretaProject_2023'
api_key='AagjVq96hOMojkDdc0fz8OJPI'
api_secret_key='DWrqQZWe2QDabVKDT5nVped8jqDk6UrPGAmJM74xX1xMIVL6Cf'
acc_token='124194957-1fvDtoNyoah7sq92QWFZ8GGsAkmmSl1xWBSgb3E3'
acc_secret_token='N29dRKpzRSgt7vCcVj8AFCuwfHUROGStK15X7HMeBWvg4'
#generate token
create_token(
app=app,
consumer_key=api_key,
consumer_secret=api_secret_key,
access_token=acc_token,
access_secret=acc_secret_token
)
## Warning: `create_token()` was deprecated in rtweet 1.0.0.
## ℹ See vignette('auth') for details
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated
.
## Saving auth to
## 'C:\Users\Pratibha\AppData\Roaming/R/config/R/rtweet/create_token.rds'
1. Followed By Greta
# Get the friends (people followed) by Greta Thunberg
set.seed(123)
greta_friends <- get_friends("GretaThunberg", n = 100000)
head(greta_friends)
## # A tibble: 6 × 2
## from_id to_id
##
## 1 GretaThunberg 42643305
## 2 GretaThunberg 1450363558483709954
## 3 GretaThunberg 1663643377215127553
## 4 GretaThunberg 1513242630217519104
## 5 GretaThunberg 1645750061438205952
## 6 GretaThunberg 1461716693437214722
# Extract the friend IDs
friend_ids <- greta_friends$to_id
# Fetch detailed information of the friends including their follower counts
friend_info <- lookup_users(user = friend_ids)
# Filter out friends who are companies or organizations
friend_info <- friend_info[!grepl("company|organization", friend_info$description, ignore.case = TRUE), ]
friend_info
## # A tibble: 2,865 × 23
## id id_str name screen_name location derived url description protected
##
## 1 4.26e 7 42643… Hong… honghoangc… "Ho Chi… http… "Environme… FALSE
## 2 1.45e18 14503… RePl… letsreplan… "Europe" http… "We’re a c… FALSE
## 3 1.66e18 16636… Peop… PeopleFFut… "" "" FALSE
## 4 1.51e18 15132… Scie… SR_Netherl… "" http… "Scientist… FALSE
## 5 1.65e18 16457… Frid… F4F_ROSA "Nepal" http… "FFF_South… FALSE
## 6 1.46e18 14617… Nich… OmonukN "Planet… http… "A Climate… FALSE
## 7 1.36e18 13632… Ende… ende_gelan… "Brunsb… http… "Climate j… FALSE
## 8 1.60e18 16023… Kari… k_nuttipil… "" "" FALSE
## 9 1.66e18 16571… XR M… XRMothersUg "Uganda" "We refuse… FALSE
## 10 8.31e 8 83100… Dr A… PerrinAbi "York, … "Molecular… FALSE
## # ℹ 2,855 more rows
## # ℹ 14 more variables: verified , followers_count ,
## # friends_count , listed_count , favourites_count ,
## # statuses_count , created_at , profile_banner_url ,
## # profile_image_url_https , default_profile ,
## # default_profile_image , withheld_in_countries , entities ,
## # withheld_scope
## ℹ Tweets data at tweets_data()
# Sort the friends based on their follower counts
top_friends <- head(friend_info[order(friend_info$followers_count, decreasing = TRUE), ], 12)
top_friends
## # A tibble: 12 × 23
## id id_str name screen_name location derived url description protected
##
## 1 8.13e5 813286 Bara… BarackObama "Washin… http… "Dad, husb… FALSE
## 2 1.88e7 18839… Nare… narendramo… "India" http… "Prime Min… FALSE
## 3 1.58e7 15846… Elle… EllenDeGen… "Califo… http… "Comedian,… FALSE
## 4 7.59e5 759251 CNN CNN "" http… "It’s our … FALSE
## 5 8.07e5 807095 The … nytimes "New Yo… http… "News tips… FALSE
## 6 4.72e8 47174… PMO … PMOIndia "India" http… "Office of… FALSE
## 7 1.94e7 19397… Opra… Oprah "" http… "" FALSE
## 8 7.42e5 742143 BBC … BBCWorld "London… http… "News, fea… FALSE
## 9 1.81e8 18050… Inst… instagram "" http… "Discover … FALSE
## 10 1.34e9 13398… Hill… HillaryCli… "New Yo… http… "2016 Demo… FALSE
## 11 2.87e7 28706… P!nk Pink "los an… http… "My new al… FALSE
## 12 1.75e7 17471… Nati… NatGeo "Global" http… "Taking ou… FALSE
## # ℹ 14 more variables: verified , followers_count ,
## # friends_count , listed_count , favourites_count ,
## # statuses_count , created_at , profile_banner_url ,
## # profile_image_url_https , default_profile ,
## # default_profile_image , withheld_in_countries , entities ,
## # withheld_scope
## ℹ Tweets data at tweets_data()
# Print summary information about the friends
class(top_friends)
## [1] "users" "tbl_df" "tbl" "data.frame"
for (i in 1:nrow(top_friends)) {
cat("Friend", i, "\n")
cat("Name:", top_friends$name[i], "\n")
cat("Followers Count:", top_friends$followers_count[i], "\n")
cat("Description:", top_friends$description[i], "\n\n")
}
## Friend 1
## Name: Barack Obama
## Followers Count: 132386379
## Description: Dad, husband, President, citizen.
##
## Friend 2
## Name: Narendra Modi
## Followers Count: 89217028
## Description: Prime Minister of India
##
## Friend 3
## Name: Ellen DeGeneres
## Followers Count: 75715030
## Description: Comedian, talk show host and ice road trucker. My tweets are real, and they’re spectacular.
##
## Friend 4
## Name: CNN
## Followers Count: 61425940
## Description: It’s our job to #GoThere & tell the most difficult stories. For breaking news, follow @CNNBRK and download our app https://t.co/ceNBoNi8y6
##
## Friend 5
## Name: The New York Times
## Followers Count: 55066472
## Description: News tips? Share them here: https://t.co/ghL9OoYKMM
##
## Friend 6
## Name: PMO India
## Followers Count: 53268439
## Description: Office of the Prime Minister of India
##
## Friend 7
## Name: Oprah Winfrey
## Followers Count: 42443961
## Description:
##
## Friend 8
## Name: BBC News (World)
## Followers Count: 39877268
## Description: News, features and analysis from the World's newsroom. Breaking news, follow @BBCBreaking. UK news, @BBCNews. Latest sports news @BBCSport
##
## Friend 9
## Name: Instagram
## Followers Count: 33351158
## Description: Discover what's next on Instagram ?✨
##
## Friend 10
## Name: Hillary Clinton
## Followers Count: 31424886
## Description: 2016 Democratic Nominee, SecState, Senator, hair icon. Mom, Wife, Grandma x3, lawyer, advocate, fan of walks in the woods & standing up for our democracy.
##
## Friend 11
## Name: P!nk
## Followers Count: 31117062
## Description: My new album TRUSTFALL out NOW ? Summer Carnival European and North American tickets on sale! ??
##
## Friend 12
## Name: National Geographic
## Followers Count: 28902510
## Description: Taking our understanding and awareness of the world further for more than 130 years
2. Followers of Greta
# Fetch followers of Greta Thunberg
set.seed(123)
followers <- get_followers("GretaThunberg", n = 10000)
head(followers)
## # A tibble: 6 × 2
## from_id to_id
##
## 1 1445129105146621963 GretaThunberg
## 2 1516813445890514955 GretaThunberg
## 3 1448607481421205504 GretaThunberg
## 4 237276143 GretaThunberg
## 5 1542950228042694656 GretaThunberg
## 6 422872595 GretaThunberg
descriptions<- lookup_users(user = followers$from_id)
library(dplyr)
# Add descriptions to the followers data frame
followers$description <- descriptions$description
followers$followers_count <- descriptions$followers_count
followers$friends_count <- descriptions$friends_count
followers$name<- descriptions$name
followers$screen_name<- descriptions$screen_name
followers$location<- descriptions$location
followers=followers[order(followers$followers_count, decreasing = TRUE), ]
top_followers=head(followers,12)
for (i in 1:nrow(top_followers)) {
cat("Follower", i, "\n")
cat("Name:", top_followers$name[i], "\n")
cat("Screen Name:", top_followers$screen_name[i], "\n")
cat("Followers Count:", top_followers$followers_count[i], "\n")
cat("Location:", top_followers$location[i], "\n\n")
cat("Description:", top_followers$description[i], "\n\n")
}
## Follower 1
## Name: Matthew VanDyke
## Screen Name: Matt_VanDyke
## Followers Count: 513006
## Location: Ukraine
##
## Description: Founder, Sons of Liberty International, #veterans training Ukrainian forces to fight Russia. A 501c3 nonprofit org: https://t.co/iJVW8PgiN9
##
## Follower 2
## Name: Giles Paley-Phillips
## Screen Name: eliistender10
## Followers Count: 407783
## Location: Seaford
##
## Description: I write books, films & produce. Half of @blankpod @forgotpodcast @unquestionpod Guitar in @burnthousemusic Ambassador for @actionaidUK Happily mediocre
##
## Follower 3
## Name: Anton Gerashchenko
## Screen Name: Gerashchenko_en
## Followers Count: 364676
## Location: Ukraine
##
## Description: Ukrainian patriot. Advisor to the Minister of Internal Affairs of Ukraine. Founder of the Institute of the Future. Official enemy of Russian propaganda
##
## Follower 4
## Name: ????? ?????
## Screen Name: pussyrrriot
## Followers Count: 245534
## Location: sugar mommy
##
## Description: spent 2 years in jail for fighting putin / global protest art movement ??? NOT a punk rock band
##
## Follower 5
## Name: Daily Star
## Screen Name: dailystar
## Followers Count: 233401
## Location: London
##
## Description: Home of Fun Stuff! Follow @StarBreaksNews to be the first to know about #BreakingNews
##
## Follower 6
## Name: Andriy Yermak
## Screen Name: AndriyYermak
## Followers Count: 210274
## Location:
##
## Description: Керівник Офісу Президента України / Head of the Office of the President of Ukraine
##
## Follower 7
## Name: ōLand by Overline
## Screen Name: overlinenetwork
## Followers Count: 162873
## Location: Jackson, WY
##
## Description: 2M+ users. Personal ownership is everything. Your crypto, your creativity, and your internet.
##
## Follower 8
## Name: Jonathan “Loda” Berg
## Screen Name: LodaBerg
## Followers Count: 139965
## Location:
##
## Description: CEO of @thealliancegg, TI3 winner, Living legend, bringer of balance.
##
## Follower 9
## Name: Orb Planet ❁ ?? Cͨliͥmͫaͣᴛⷮeͤ ? Blue ?⚓
## Screen Name: OrbPlanet
## Followers Count: 89955
## Location: ? ??ℝ?ℍ ? ?
##
## Description: #ClimateActionNow?#Science?#?????????????
##
## ?#VoteBlue ?#S̅o̅l̅a̅r?#E̷l̷e̷c̷t̷r̷i̷f̷y̷ ⚡
##
## #Renewables?#Nature #Oceans ?#Ecocide?#Pollution
##
## Follower 10
## Name: UkrARMY cats & dogs
## Screen Name: UAarmy_animals
## Followers Count: 87971
## Location: Kyiv
##
## Description: We fight for freedom and for Ukraine. For donates PayPal: [email protected] and https://t.co/ETJVHY357A
##
## Follower 11
## Name: Vox Populi Noticias
## Screen Name: VoxPopuliNoti
## Followers Count: 73885
## Location: Victoria, Tamaulipas
##
## Description:
##
## Follower 12
## Name: Edinburgh International Book Festival
## Screen Name: edbookfest
## Followers Count: 68609
## Location: Edinburgh
##
## Description: The world's largest public celebration of the written word.
## Next Festival: 12-28 Aug 23, Programme Released: 14 Jun 23,
## Tickets on Sale: 29 Jun 23 #EdBookFest
library(rtweet)
head(top_followers)
## # A tibble: 6 × 8
## from_id to_id description followers_count friends_count name screen_name
##
## 1 431071870 Gret… "Founder, … 513006 382398 "Mat… Matt_VanDy…
## 2 23483816 Gret… "I write b… 407783 100186 "Gil… eliistende…
## 3 15054819498… Gret… "Ukrainian… 364676 883 "Ant… Gerashchen…
## 4 2479224200 Gret… "spent 2 y… 245534 1005 "\U0… pussyrrriot
## 5 20442930 Gret… "Home of F… 233401 3861 "Dai… dailystar
## 6 11492710283… Gret… "Керівник … 210274 209 "And… AndriyYerm…
## # ℹ 1 more variable: location
# Retrieve the latest tweets of the top followers
tweets <- lapply(top_followers$from_id, function(user_id) {
get_timeline(user = user_id, n = 200)
})
# Retrieve the latest tweets of the top followers
tweets <- lapply(top_followers$from_id, function(user_id) {
get_timeline(user = user_id, n = 200)
})
# Add follower_id column to each data frame in the list
tweets <- Map(function(df, follower_id) {
df$follower_id <- follower_id
df
}, tweets, top_followers$from_id)
# Combine all the data frames into a single data...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here