Skip to content

Compose and publish twitter threads from the comfort of your R session or from rmarkdown rendering.

License

Notifications You must be signed in to change notification settings

eliocamp/spindler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spindler

Lifecycle: experimental

The goal of spindler is to extend reproducible reporting to Twitter threads. Simply by adding a few lines into a rmarkdown document, you can publish a thread with selected results and short comments.

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("eliocamp/spindler")

Setup

Spinder uses rtweet to publish your tweets, so you'll need to go over its basic configuration of obtaining and using access tokens.

Manually crafted:

birds <- spindler::thread$new()
birds$add_post("Hey, people, I want to tell you how awesome birds are!")$
  add_post("They have feathers, and (most of them) can fly!")$
  add_post("And look how cute they ares", media = "~/Pictures/penguin1.png")

Take a look at it either in plain text format by printing it:

birds
#> 1: Hey, people, I want to tell you how awesome birds are!
#>    | 
#> 2: They have feathers, and (most of them) can fly!
#>    | 
#> 3: And look how cute they ares
#>    /home/elio/Pictures/penguin1.png
#>    |

Or with a shiny app:

birds$preview()

All looks good, let's publish it and open it in a browser.

birds$publish()
birds$browse()

Oh, no I made a typo. Quick, delete the whole thing!

birds$destroy()

Let's start over

birds$clear()$
  add_post("Nooo! I had an awesome thread about birds, but I messed up.")$
  add_post("So here's the jist of it: birds rock and they are better than monkeys!")$
  publish()

From knitr

Create a new thread object with a tag assigned.

```{r, setup}
this_thread <- spindler::thread$new(tag = "tw_status")
```

Now if you add the tw_status option to a chunk with the text you want to tweet, it will be added to the thread along with its first figure (if there is one) during the rendering process.

```{r, tw_status = "The relationship between pressure and temperature is cool!"}
plot(pressure)
```

You can also use this_thread$add_post() inside your knitr document to add posts manually. At the point where you want to publish your post, do it from inside a new chunk. It's recomended that you also save your thread.

```{r}
this_thread$publish()$save()$browse()
```

Afterwards you can load the latests saved thread with thread$new()$load().

About

Compose and publish twitter threads from the comfort of your R session or from rmarkdown rendering.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages