knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-", eval = FALSE )
A simple wrapper to tweet straight from your R session.
Open a widget to send tweets (you'll need a Twitter token to do that)
Opens your browser with a text ready to tweet. You need to add a text, and url & via are optional.
devtools::install_github("ColinFay/tweetthat")
Using the widget allows you to send images from your computer:
Before using the widget, you should create a Twitter App with read and write permission on apps.twitter.com. Then run :
## whatever name you assigned to your created app appname <- "myapp" ## api key (example below is not a real key) key <- "84618490-BpSmqfwIWx6ZkeFDVg6FDZ7LUsMRrzdBPzuc1YT" ## api secret (example below is not a real key) secret <- "EWXOpTjIpqM8EmHCGHd5xGQKFeCsUfeqWk5NgPtLIRi" ## create token named "twitter_token" twitter_token <- rtweet::create_token( app = appname, consumer_key = key, consumer_secret = secret)
(taken from the rtweet vignette)
You can check the .Renviron variable is set well with:
usethis::edit_r_environ()
There should be a TWITTER_PAT=
var here, with a link to a .Rds.
The function doesn't need a Twitter token, but you can't send image from your computer.
library(tweetthat) tweet_that(text = "I wrote this tweet in RStudio, how cool is that?")
tweet_that(text = "This website is awesome", url = "http://colinfay.me")
tweet_that(text = "Colin's Twitter is full of advices", via = "@_colinfay")
tweet_that(text = "#RStats — Colin's website is cool", url = "http://colinfay.me", via = "@_colinfay")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.