Forked from yonicd/anandwrite_twitter_survey_replies.R
Created
April 12, 2019 14:51
-
-
Save igorbrigadir/cb4fc2acc4d070847930f99880c585e5 to your computer and use it in GitHub Desktop.
code to retrieve @anandwrites adhoc survey replies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(magrittr) | |
library(rtweet) | |
root_status <- '1116361675618361345' | |
x1 <- rtweet::lookup_tweets(root_status) | |
# The question | |
cat(x1$text) | |
#> Who do you: | |
#> | |
#> (A) most want to win the Democratic primary? | |
#> | |
#> (B) least want to win the Democratic primary? | |
#> | |
#> (C) anticipate will win the Democratic primary? | |
query <- sprintf('to:%s since:%s',x1$screen_name,as.Date(x1$created_at)) | |
query_result <- rtweet::search_tweets(query,n = 2000) | |
#filter out replies to root status | |
status_replies <- query_result[query_result$reply_to_status_id==root_status,] | |
#remove any NA reply_to_status_id | |
status_replies <- status_replies[!is.na(status_replies$reply_to_status_id),] | |
# number of answers | |
nrow(status_replies) | |
#> [1] 1222 | |
# non formated answers to tabulate (first 5) | |
cat(paste(head(status_replies$text),collapse = '\n\n')) | |
#> @AnandWrites A) Andrew Yang | |
#> B) Elizabeth Warren | |
#> C) Joe Biden | |
#> | |
#> @AnandWrites (A) Warren / Sanders | |
#> (B) Biden | |
#> (C) Biden / Harris | |
#> | |
#> @AnandWrites Buttigieg | |
#> Biden | |
#> Harris | |
#> | |
#> @AnandWrites A) Any living thing | |
#> B) The media consensus | |
#> C) Don Jr | |
#> | |
#> @AnandWrites @berniemyman2020 A) Bernie | |
#> B) Biden | |
#> C) probably Kamala, which isn't great but is miles better than Biden | |
#> | |
#> @AnandWrites A) Warren | |
#> B) Biden | |
#> C) Biden or Sanders (I’d be happy with Sanders) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment