Learn R Programming

rtweet (version 0.4.0)

get_timeline: get_timeline

Description

Returns timeline of tweets from a specified Twitter user. By default, get_timeline returns tweets posted by a given user. To return a user's timeline feed, that is, tweets posted by accounts you follow, set the home argument to true.

Usage

get_timeline(user, n = 200, max_id = NULL, home = FALSE, parse = TRUE,
  check = TRUE, usr = TRUE, token = NULL, ...)

Arguments

user

Screen name or user id of target user.

n

Numeric, number of tweets to return.

max_id

Character, status_id from which returned tweets should be older than.

home

Logical, indicating whether to return a user-timeline or home-timeline. By default, home is set to FALSe, which means get_timeline returns tweets posted by the given user. To return a user's home timeline feed, that is, the tweets posted by accounts followed by a user, set the home to false.

parse

Logical, indicating whether to return parsed (data.frames) or nested list (fromJSON) object. By default, parse = TRUE saves users from the time [and frustrations] associated with disentangling the Twitter API return objects.

check

Logical indicating whether to remove check available rate limit. Ensures the request does not exceed the maximum remaining number of calls. Defaults to TRUE.

usr

Logical indicating whether to return users data frame. Defaults to true.

token

OAuth token. By default token = NULL fetches a non-exhausted token from an environment variable. Find instructions on how to create tokens and setup an environment variable in the tokens vignette (in r, send ?tokens to console).

Futher arguments passed on to make_url. All named arguments that do not match the above arguments (i.e., count, type, etc.) will be built into the request. To return only English language tweets, for example, use lang = "en". Or, to exclude retweets, use include_rts = FALSE. For more options see Twitter's API documentation.

Value

List consisting of two data frames. One with the tweets data for a specified user and the second is a single row for the user provided.

See Also

https://dev.twitter.com/overview/documentation

Other tweets: get_favorites, lookup_statuses, search_tweets, stream_tweets, tweets_data

Examples

Run this code
# NOT RUN {
# get 2000 from Donald Trump's account
djt <- get_timeline("realDonaldTrump", n = 2000)

# data frame where each observation (row) is a different tweet
djt

# users data for realDonaldTrump is also retrieved.
# access it via users_data() users_data(hrc)
users_data(djt)
# }

Run the code above in your browser using DataLab