Hi all, I work with academic twitter and trying to create a network between author tweets from a specific place with authors who replies to the conversation.
I have a data frame with different tweets for instance:
df_tweet_place
id Author id Conversation Id Text
#> 1 5.1 3.5 1.4 Hola desde Perú
#> 2 4.9 3.0 1.9 Olas grandes
#> 3 4.7 3.2 1.3 Alerta costera ,@
#> 4 4.6 3.1 1.5 Quien sale hoy con esta lluvia
#> 5 5.0 3.6 1.8 Se viene la lluvia
.......
#> 206 5.4 3.9 1.7 Chao turistas
To get the reply of each twitter (id) I have to run a specific function from academic twitter using id conversation.
Code:
A loop to go through the 206 id conversation of df_tweets
for (i in 1:206){
df.reply <- get_all_tweets(build_query(conversation_id = df_tweets$conversation_id[i]), start_tweets = "2010-01-01T00:00:00Z", end_tweets = "2022-01-01T00:00:00Z"){
If the conversation (i) has a reply I will get something like this
author id Converstation id Author id Sensiivte
#> 1 45 3.5 1.4 False
#> 2 47 3.0 1.4 True
#> 3 89 3.2 1.4 False
#> 4 46 3.1 1.4 false
#> 5 53 3.6 1. 4 true
Wich means that 5 people answer to the conversation id of df. tweets. This function will have to run 206 times since I have 206 tweets with their I conversation
######## next steps are clean the data frame and add the result of each loop to an empty data already created.
df.reply_clean<-df.reply%>%select(author_id,conversation_id)
df.replytotal <- rbind(df.replytotal, df.reply_clean)
}
Having something like this as a results
df.replytotal<-
author id Converstation id
#> 1 45 1.4
#> 2 47 1.4
#> 3 89 1.4
#> 4 46 1.4
#> 5 53 1. 4
#>6 68 1.9
#>6 37 1.9
#>8 122 1.3
However, there is some conversation id that doesn't have a reply so the loop stops and can keep running. I don't know how to make the condition that say
if df.reply is null or empty ( 0 observation) go to the next conversation id from df.tweets_place run df.reply again until get some observation and continue in the next step that is:
df.replay_clean and df.replay.total
any suggestion would be great!!!
Thanks!!