Learn R Programming

rtweet (version 0.6.9)

as_screenname: Coerces user identifier(s) to be evaluated as a screen name(s).

Description

Coerces user identifier(s) to be evaluated as a screen name(s).

Usage

as_screenname(x)

as_userid(x)

Arguments

x

A vector consisting of one or more Twitter user identifiers (i.e., screen names or user IDs).

Value

A vector of class screen_name or class user_id

Details

Default rtweet function behaviors will treat "1234" as a user ID, but the inverse (i.e., treating "2973406683" as a screen name) should rarely be an issue. However, in those cases, users may need to mix both screen names and user IDs. To do so, make sure to combine them as a list (and not a character vector, which will override conflicting user identifier classes). See examples code for example of mixing user IDs with screen names. Note: this only works with certain functions, e.g., get_friends, get_followers.

See Also

Other users: lists_subscribers, lookup_users, search_users, tweets_with_users, users_data

Examples

Run this code
# NOT RUN {
## get friends list for user with the handle "1234"
get_friends(as_screenname("1234"))

## as_screenname coerces all elements to class "screen_name"
sns <- as_screenname(c("kearneymw", "1234", "jack"))
class(sns)

## print will display user class type
sns

## BAD: combine user id and screen name using c()
users <- c(as_userid("2973406683"), as_screenname("1234"))
class(users)

## GOOD: combine user id and screen name using list()
users <- list(as_userid("2973406683"), as_screenname("1234"))
users

## get friend networks for each user
get_friends(users)

# }

Run the code above in your browser using DataLab