Chapter 4 Prerequisites

In this chapter we get you set up and running with the twinetverse, namely the package installation and setting up rtweet to fetch tweets.

4.1 Install

The package can be installed with devtools (Wickham, Hester, and Chang 2018) or remotes (Csárdi et al. 2017), it is available from Github or Bitbucket:

The twinetverse package can be installed from Github:

or from Bitbucket:

In the book we don’t explicitly load the package and assume you have it loaded in your environment.

4.2 Setup rtweet

The rtweet package requires some set up. This is not only extremely easy but also very well explained on rtweet’s official website, so head over there if the short description below does not satisfy.

In essence, you will need a Twitter “app” to access its API, to create one:

  1. Head over to and login or signup if you do not have a Twitter account.
  2. Click create an app.
  3. In the following form, enter an app name, whatever you want, this does not matter.
  4. Enter a description, then again, it doesn’t matter.
  5. Website, simply put a valid website, you can link to your Twitter profile if you do not have one, i.e.:
  6. Callback URL, this is important, in there put the following:, exactly as is.

You’re now setup with an app, take note of the crendentials of your app under “Keys and Access Tokens”, as you will need it to create your token and fetch tweets:

  • Consumer Key (consumer_key)
  • Consumer Secret (consumer_secret)
  • Access Token (access_token)
  • Access Token Secret (access_secret)

Do NOT share those credentials or your token with anyone.

Create your token with like so.

Ideally, also save it. There is no need to re-create a token everytime you want to download data. Once saved you can easily load it readRDS (we’ll demonstrate that in the next chapter).

You’re all set to use the twinetverse!


Wickham, Hadley, Jim Hester, and Winston Chang. 2018. Devtools: Tools to Make Developing R Packages Easier.

Csárdi, Gábor, Hadley Wickham, Winston Chang, Jim Hester, Martin Morgan, and Dan Tenenbaum. 2017. Remotes: R Package Installation from Remote Repositories, Including ’Github’.