search_users: search_users

Description Usage Arguments Value See Also Examples

View source: R/search.R

Description

Returns data frame of users data using a provided search query.

Usage

1
2
search_users(q, n = 20, parse = TRUE, tw = TRUE, token = NULL,
  verbose = TRUE)

Arguments

q

Query to be searched, used in filtering relevant tweets to return from Twitter's REST API. Should be a character string not to exceed 500 characters maximum. Spaces are assumed to function like boolean "AND" operators. To search for tweets including one of multiple possible terms, separate search terms with spaces and the word "OR". For example, the search query = "data science" searches for tweets using both "data" and "science" though the words can appear anywhere and in any order in the tweet. However, when OR is added between search terms, query = "data OR science", Twitter's REST API should return any tweet that includes either "data" or "science" appearing in the tweets. At this time, Twitter's users/search API does not allow complex searches or queries targetting exact phrases as is allowed by search_tweets.

n

Numeric, specifying the total number of desired users to return. Defaults to 100. Maximum number of users returned from a single search is 1,000.

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.

tw

Logical indicating whether to return tweets 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).

verbose

Logical, indicating whether or not to output processing/retrieval messages.

Value

Data frame of users returned by query.

See Also

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

Other users: lookup_users, users_data

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
# search for 1000 tweets mentioning Hillary Clinton
pc <- search_users(q = "political communication", n = 1000)

# data frame where each observation (row) is a different user
pc

# tweets data also retrieved. can access it via tweets_data()
users_data(hrc)

## End(Not run)

rtweet documentation built on May 30, 2017, 4:37 a.m.

Search within the rtweet package
Search all R packages, documentation and source code