0

I'd like to explore Twitter's API to do sentiment analysis via the emojis used in tweets containing certain keywords or hashtags. (Like what PRISMOJI do: https://twitter.com/PRISMOJI?s=09)

But I've never done this before - any pointers on the script?

I'm using rtweet to explore the API, but open to other tools - but hopefully in R.

UPDATE

So I've written some code and solved my original issue. Woop!)

install.packages("rtweet")
library(rtweet)
install.packages("tidyverse")
library(tidyverse)
install.packages("tidytext")
library(tidytext)
insrall.packages("httpuv")
library(httpuv)


api_key <- 'api key entered here'

api_secret <- 'api secret entered here'

access_token <- 'token entered here'

access_token_secret <- 'key entered here'

token <- create_token(
  app = "my app name",
  consumer_key = api_key,
  consumer_secret = api_secret
  access_token = access_token,
  access_secret = access_token_secret)

tweets <- search_tweets(q ="#CleanDishwasher", n = 18000, include_rts = FAKSE, `-filter` = "replies", lang = "en")

## get coordinates associated with the following addresses/components

write_as_csv(tweets, "tweets.csv")

sydney <- lookup_coords("sydney", "country:AU")

## pass a returned coords object to search_tweets

sydney_tweets <- search_tweets(geocode = sydney)

##find top emojis
library(emo)
sydney_tweets %>%
  mutate(emoji = ji_extract_all(text)) %>%
  unnest(cols = c(emoji)) %>%
  count(emoji, sort = TRUE) %>%
  top_n(10)
4

1 Answer 1

0

When setting my access keys and tokens, I had mistakenly used access_token_secret rather than access_secret.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.