https://github.com/eliocamp/spindler
Compose and publish twitter threads from the comfort of your R session or from rmarkdown rendering.
https://github.com/eliocamp/spindler
Last synced: over 1 year ago
JSON representation
Compose and publish twitter threads from the comfort of your R session or from rmarkdown rendering.
- Host: GitHub
- URL: https://github.com/eliocamp/spindler
- Owner: eliocamp
- License: gpl-3.0
- Created: 2019-06-07T23:26:36.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-12T18:49:01.000Z (over 3 years ago)
- Last Synced: 2024-05-01T13:59:22.975Z (about 2 years ago)
- Language: R
- Size: 244 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# spindler 
[](https://www.tidyverse.org/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](https://github.com) with:
``` r
# install.packages("devtools")
devtools::install_github("eliocamp/spindler")
```
## Setup
Spinder uses [rtweet](https://rtweet.info) to publish your tweets, so you'll need to
go over its basic configuration of [obtaining and using access tokens](https://rtweet.info/articles/auth.html).
### Manually crafted:
```r
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:
```r
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:
```r
birds$preview()
```

All looks good, let's publish it and open it in a browser.
```r
birds$publish()
birds$browse()
```
Oh, no I made a typo. Quick, delete the whole thing!
```{r}
birds$destroy()
```
Let's start over
```{r}
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
```{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
```{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
```{r}
this_thread$publish()$save()$browse()
```
````
Afterwards you can load the latests saved thread with `thread$new()$load()`.