开发者

Get tweet-count via twitteR-package

开发者 https://www.devze.com 2023-02-25 10:15 出处:网络
I\'m having some trouble with R and the twitteR-package. My aim is to get the total tweet from a given user. The user-class开发者_开发知识库 offers a statusesCount-field. I don\'t know how to get the

I'm having some trouble with R and the twitteR-package.

My aim is to get the total tweet from a given user. The user-class开发者_开发知识库 offers a statusesCount-field. I don't know how to get the value from this field.

The vignette only offers examples with tweets from public timelines and even there I can't get the total counts.

The example in the vignette looks like this (p. 5):

sapply(publicTimeline(), function(x) x$getStatusSource())

I can extract even the ScreenName or the user-ID:

sapply(publicTimeline(), function(x) x$getScreenName())

sapply(publicTimeline(), function(x) x$getID())

In fact, the publicTimeline-function catches random users and I'd like to have given users.

Anyone can help me?

Regards,

Arne


You'll want to first getUser for a specific user. Then, you can use str() to understand the structure of that user. The @ symbol is used to access fields in S4 objects.

Example:

> library(twitteR)
> user <- getUser("@twitter")
> user@statusesCount
[1] 1087
0

精彩评论

暂无评论...
验证码 换一张
取 消