First of all, you need to create a Twitter application.
Click the Create New App button
Give a name and description to your app.
Enter a valid web site address in the Website field.
In the Callback URL field write: http://127.0.0.1:1410
Agree the developer agreement and click the Create your Twitter application button.
You will see two important numbers, the customer key (API key) and the consumer secret (api secret).
We will use them in the next steps.
now, in your R workspace:
Include twitteR and httpuv libraries in your current workspace:
Use twitter API to your recently created app:
setup_twitter_oauth("your consumer key", "your consumer secret")
When asked if want to use a local file to auth in twitter enter No.
Wait until your internet explorer opens to authorize your app to use your twitter account.
You should now be able to use twitter API.