I am working in R and trying to extract the number of total likes and comments for a list of twitter handles. I am completely clueless, any help will be appreciated. I have set up the API and installed the necessary libraries.
Any leads will be appreciated, thank you
install.packages("twitteR")
library(twitteR)
install.packages("rtweet")
library(rtweet)
install.packages("tidytext")
library(tidytext)
install.packages("httr")
library(httr)
install.packages("RCurl")
library(RCurl)
install.packages("plyr")
library(plyr)
install.packages("RJSONIO")
library(RJSONIO)
install.packages("stringr")
library(stringr)
install.packages("ROAuth")
library(ROAuth)
#Setting up twitter API
consumer_key <- "key"
consumer_secret <- "key"
access_token <- "key"
access_secret <- "key"
options(httr_oauth_cache=T)
setup_twitter_oauth(consumer_key,
consumer_secret,
access_token,
access_secret)
#reading csv and extracting the followers and tweets count
users <- read.csv("Twitter.csv", skip = 1)
users1 <- lookupUsers(users[1:50,1])
In R, using rtweet, below is the information you will get about a user
EDIT
Based on your updated code. Below is a reproducible example.
rtweet::lookup_usersonly works on objects of classcharacterWhereas, with a
charactervector all goes well.rtweet::lookup_usersonly works on objects of classcharacterSo when you read the csv with
read.csvsetstringsAsFactors = FALSElike so.Note the above is based on the
rtweetpackage, I strongly suggest you switch from usingtwitteR, as stated on thetwitteRgithub page.