如何获得twitter句柄列表的喜欢和评论数
我在R工作,试图为twitter句柄列表提取总喜欢数和评论数。我完全不知所措,任何帮助都将不胜感激。我已经设置了API并安装了必要的库 任何线索都将不胜感激,谢谢如何获得twitter句柄列表的喜欢和评论数,r,twitter,count,social-likes,R,Twitter,Count,Social Likes,我在R工作,试图为twitter句柄列表提取总喜欢数和评论数。我完全不知所措,任何帮助都将不胜感激。我已经设置了API并安装了必要的库 任何线索都将不胜感激,谢谢 install.packages("twitteR") library(twitteR) install.packages("rtweet") library(rtweet) install.packages("tidytext") library(tidytext) install.packages("httr") library(
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])
install.packages(“twitteR”)
图书馆(推特)
安装.packages(“rtweet”)
图书馆(rtweet)
install.packages(“tidytext”)
图书馆(tidytext)
安装程序包(“httr”)
图书馆(httr)
安装程序包(“RCurl”)
图书馆(RCurl)
安装软件包(“plyr”)
图书馆(plyr)
安装软件包(“RJSONIO”)
图书馆(RJSONIO)
安装程序包(“stringr”)
图书馆(stringr)
安装程序包(“ROAuth”)
图书馆(ROAuth)
#设置twitterapi
消费者密钥在R中,使用,下面是您将获得的有关用户的信息
library(rtweet)
x <- rtweet::lookup_users("jdatap")
names(x)
[1] "user_id" "status_id" "created_at"
[4] "screen_name" "text" "source"
[7] "display_text_width" "reply_to_status_id" "reply_to_user_id"
[10] "reply_to_screen_name" "is_quote" "is_retweet"
[13] "favorite_count" "retweet_count" "hashtags"
[16] "symbols" "urls_url" "urls_t.co"
[19] "urls_expanded_url" "media_url" "media_t.co"
[22] "media_expanded_url" "media_type" "ext_media_url"
[25] "ext_media_t.co" "ext_media_expanded_url" "ext_media_type"
[28] "mentions_user_id" "mentions_screen_name" "lang"
[31] "quoted_status_id" "quoted_text" "quoted_created_at"
[34] "quoted_source" "quoted_favorite_count" "quoted_retweet_count"
[37] "quoted_user_id" "quoted_screen_name" "quoted_name"
[40] "quoted_followers_count" "quoted_friends_count" "quoted_statuses_count"
[43] "quoted_location" "quoted_description" "quoted_verified"
[46] "retweet_status_id" "retweet_text" "retweet_created_at"
[49] "retweet_source" "retweet_favorite_count" "retweet_retweet_count"
[52] "retweet_user_id" "retweet_screen_name" "retweet_name"
[55] "retweet_followers_count" "retweet_friends_count" "retweet_statuses_count"
[58] "retweet_location" "retweet_description" "retweet_verified"
[61] "place_url" "place_name" "place_full_name"
[64] "place_type" "country" "country_code"
[67] "geo_coords" "coords_coords" "bbox_coords"
[70] "status_url" "name" "location"
[73] "description" "url" "protected"
[76] "followers_count" "friends_count" "listed_count"
[79] "statuses_count" "favourites_count" "account_created_at"
[82] "verified" "profile_url" "profile_expanded_url"
[85] "account_lang" "profile_banner_url" "profile_background_url"
[88] "profile_image_url"
然而,有了字符
向量,一切都很顺利
因此,当您使用read.csv
读取csv时,设置stringsAsFactors=FALSE
如下
users <- read.csv("Twitter.csv", skip = 1, stringsAsFactors = FALSE)
用户请添加更多详细信息。您正在尝试使用什么API和库,到目前为止您已经开始编写什么,等等。请使请求更加简洁,以说明您正在尝试完成的任务。现在要求有人为你写这封信。欢迎来到SO!请阅读并给出答案!非常感谢。它给了我一个错误“readRDS(x)中的错误:从连接读取错误”。您知道问题出在哪里吗?在rtweet::lookup\u users
上,您从哪里得到这个错误?检查rtweet[获取和使用访问令牌](),它解释了如何获取令牌。然后使用rtweet::lookup_users(“jdatap”,token=your_token)
其中your_token
是create_token
返回的对象(即:您的\u标记我成功创建了一个标记,但当我尝试使用诸如retweet\u location之类的标签时,它会显示function not AvailableEyes,这很有帮助。谢谢您当我使用您的编辑时,它会显示错误:“lookup\u user”不是从“namespace:rtweet”导出的对象。您知道为什么会这样吗?我已经安装了rtweet和所有其他必要的工具。)ry软件包
users <- data.frame(
name = c("jdatap", "dataandme")
)
class(users$name)
[1] "factor"
rtweet::lookup_users(users = users$name)
data frame with 0 columns and 0 rows
users <- data.frame(
name = c("jdatap", "dataandme"),
stringsAsFactors = FALSE
)
users <- data.frame(
name = c("jdatap", "dataandme"),
stringsAsFactors = FALSE
)
class(users$name)
[1] "character"
# works just not showing huge output here
users <- rtweet::lookup_users(users = users$name)
users <- read.csv("Twitter.csv", skip = 1, stringsAsFactors = FALSE)