update_twitter_user: Update or get tweets from a Twitter wall

Description Usage Arguments Value Examples

View source: R/update_twitter_users.R

Description

This function updates one Twitter user's wall with rtweet's get_timeline() function. It looks for a previously stored data.frame (readable by readRDS). If there is one, it tries to scrape newer and older tweets than the ones already stored in the data.frame. Otherwise it creats a new data.frame.

Usage

1
2
3
4
5
6
7
8
update_twitter_user(
  user,
  datafile,
  n = 100,
  token = NULL,
  max_repeats = 100,
  debug = FALSE
)

Arguments

user

A twitter user name or ID.

datafile

The full path to an RDS data file.

n

The number of tweets to scrape from the wall, 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 if it ran 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")

# The BBC World news Twitter feed is scraped and stored in the user's home
# folder in the directory "temp" as "bbc_world.rds". If the file does not
# already exist a new file is created. If it exists, the existing data is
# updated.
update_twitter_feed("BBCWorld", "~/temp/bbc_world.rds")

# The data set can be loaded with readRDS
readRDS("~/temp/bbc_world.rds")

## End(Not run)

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