Send tweets from R: A very short walkthrough
This article is originally published at https://rcrastinate.blogspot.com/There are a few reasons why you might want to send tweets from R. You might want to write a Twitter bot or - as in my case - you want to send yourself a tweet when a very long computation finishes.
So, here I will run you through all the steps you have to take using
- Twitter's API and
- the twitteR package written by Jeff Gentry
The setup to send myself tweets is the following: I have my main twitter account and an additional account I am only using to tweet from R. I am following the additional account with my main account. On my phone's Twitter app, my main account is logged in and notifications are activated only for the additional account. So, whenever I tweet something with the additional account, the new tweet pops up on my phone.
Let's get started.
Step 1: Create an additional twitter account and log in with this one.
Step 2: Go to apps.twitter.com (Application Management) and create a new app. After completing the process your Application Management main screen should look something like this.
setup_twitter_oauth(consumer_key = "<your Consumer Key>",
access_token = "<your Acces Token>",
consumer_secret = "<your Consumer Secret>",
access_secret = "<your Access Token Secret>")
gauss <- rnorm(n = 10000)
jpeg("temp.jpg")
plot(density(gauss))
dev.off()
t2 <- difftime(Sys.time(), t1, units = "secs")
tw <- updateStatus(paste("Finished in", round(t2, 2), "seconds"), mediaPath = "temp.jpg")
Thanks for visiting r-craft.org
This article is originally published at https://rcrastinate.blogspot.com/
Please visit source website for post related comments.