- 3 Minutes Wednesdays
- Posts
- 3MW (Storing {pins} on GitHub and AWS S3)
3MW (Storing {pins} on GitHub and AWS S3)
Enjoy 3 Minute Wednesdays at no cost.
This newsletter is brought to you for free. If you want to advance your R skills and support my work at the same time, then you will like my paid offerings:
Guten Tag!
Many greetings from Munich, Germany. In this week’s newsletter, I’ll show you how to use the {pins}
package to store your data on different online platforms. Basically, this is a follow-up to last week’s newsletter.
And there are many places where you can store pins. Here, we’ll walk through two particuclar examples. Namely, GitHub and AWS S3. But before I show you how they work, let me show you my usual announcements.
Interactive Documents > Full App
Ever found yourself building a Shiny app that contains mostly text with just a few interactive parts? That’s a bit of a nuisance to set up because you’re mostly trying to make your text look nice inside your app’s big blank canvas.
Now here’s a better way.
Just create a Quarto document! This will immediately use formatting that is proper for text-heavy documents.
And the interactive part?
Well, in Quarto you can add them via Shiny server code chunks. And in my newest YT video I show you how that works. Check it out:
Using GitHub as a Pin Board
Let’s assume you have a public GitHub repository with pins stored in it. You can connect to it using the board_url()
function. Here’s an example of that using pins from the public {pins}
repo.

Once you’ve created the board, you can read pins from it using the pin_read()
function:

But this only works with pins that contain actual R data sets. For example the raw
pin contains a .txt
file. That’s why it can’t be opened in the R console.

Instead, you have to download the file.

Using GitHub with Private Repos
What if you want to use a private repository instead?
In that case, you’ll need to include your GitHub Personal Access Token in the request. You do this by first creating a named vector with your token as the authorization header.

And then you could pass it to the headers
argument of board_url()
. Here, I’ve just taken the example from the {pins}
docs.

Limitations of Pins with GitHub
Note that using pins like that only allows reading from GitHub. It doesn’t let you modify the data. If you want to change pins from a GitHub repo, you’d have to:
Clone the repository
Modify the pins locally
Push the changes back to GitHub
This isn’t the most convenient workflow. That’s why I prefer other options like AWS S3.
Using AWS S3 as a Pin Board
For a smoother experience, AWS S3 is a great option.
To use it, you need an existing S3 bucket to store your pins. If you don’t have one yet, check out the tutorial I wrote a few weeks back on how to create an S3 bucket.
Once you have your bucket and region ready, you can connect using the board_s3()
function:

If you encounter an “Access Denied” error, it’s likely because your AWS credentials are not set up correctly. You need to have the following environment variables configured:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
You can set these in your .Renviron
file or in your R session.
Writing Pins to AWS S3
Once your S3 board is set up and authenticated, you can read and write pins just like with a local board.

The key benefit here is that you don’t need to manually download or push data. {pins}
handles it all automatically. In fact, if you take a look at your S3 bucket now, you’ll see that the data is already there.

With that, you have two solid ways to store your pins online. Next week, I’ll show you how to set up an automation on GitHub Actions that automatically collects time series data and stores it using the {pins}
package.
As always, if you have any questions, or just want to reach out, feel free to contact me by replying to this mail or finding me on LinkedIn or on Bluesky.
See you next week,
Albert 👋
Enjoyed this newsletter? Here are other ways I can help you:
Reply