knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-", 
  eval = FALSE
)

tweetthat

lifecycle

A simple wrapper to tweet straight from your R session.

Install

devtools::install_github("ColinFay/tweetthat")

With the widget

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.

With the function

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")


ColinFay/tweetthat documentation built on May 21, 2019, 2:31 a.m.