update_twitter_users: Update multiple Twitter users' timelines

Description Usage Arguments Value Examples

View source: R/update_twitter_users.R

Description

This function updates multiple Twitter users' timelines with rtweet's get_timeline() function. It makes use of the update_twitter_user function in this package. For each user in the provided character vector users it looks for a previously stored data.frame (stored in the datadir under the name provided in the named vector "users" with the file extension .rds). If there is one, it tries to scrape newer and older tweets than the ones already stored in the data.frame. Otherwise it creates a new data.frame.

Usage

1
2
3
4
5
6
7
8
update_twitter_users(
  users,
  datadir = "./raw-data",
  n = 100,
  token = NULL,
  max_repeats = 100,
  debug = FALSE
)

Arguments

users

A named character vector. Names are the data file names, characters are the Twitter user names that will be updated (see example).

datadir

A directory containing the stored data sets (as "name.rds").

n

The number of posts to scrape from each page, defaults to 100.

token

Provide a token, defaults to NULL.

max_repeats

The number of repeated calls to scrape data backwards. If go_back is TRUE, there will be repeated calls to go back in time (each call gets the number of posts in n_posts). The backward scraping will stop after max_repeats is reached. Defaults to 100.

debug

Show more messages during the updating process, default is FALSE.

Value

TRUE for all pages the update went through.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
# You have to authenticate with Twitter's API first. For more in this visit
# rtweet documentation.
rtweet::create_token(app = "R_app",
                     consumer_key = "1234",
                     consumer_secret = "1234",
                     access_token = "1234",
                     access_secret = "1234")

# A character vector is created
my_users <- c(cnn = "CNN",
              bbc_world = "BBCWorld")

# CNN's and BBC's Twitter walls are updated and the results are stored in
# the user's home directory in the folder "temp". They are named cnn.rds and
# bbc_world.rds. If they do not already exist, both data sets are created.
update_twitter_users(users = my_users, datadir = "~/temp")

## End(Not run)

jogrue/RfacebookHelperFunctions documentation built on May 7, 2020, 2:03 p.m.