rstudio / Pins
Programming Languages
Projects that are alternatives of or similar to Pins
Overview
You can use the pins
package to:
- Pin remote resources locally.
- Discover new resources across different boards.
- Share resources in local folders, with RStudio Connect, on S3, and more.
Installation
# Install the released version from CRAN:
install.packages("pins")
Usage
To begin using the pins package, you must create a board. A good place to start is the local board, which stores pins in a local directory. Here I use a temporary board, so that you can run these examples without messing up the other data you might have pinned:
library(pins)
b <- board_temp()
b
#> Pin board <pins_board_local>
#> Path: '/tmp/RtmpPhF1aa/pins-22ee6a395d22'
#> With 0 pins: ''
Next you need to store some data in that board with pin_write()
:
b %>% pin_write(head(mtcars), "mtcars")
b
#> Pin board <pins_board_local>
#> Path: '/tmp/RtmpPhF1aa/pins-22ee6a395d22'
#> With 1 pins: 'mtcars'
Later, you can retrieve that data with pin_read()
:
b %>% pin_read("mtcars")
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
#> Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
#> Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
#> Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
#> Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2
#> Valiant 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1
This can be convenient when working locally, but the real power of pins comes when you use a shared board, because because the writer and reader can be different people (or automated processes).
For example, if you use RStudio Connect, you can pin data to shared board:
b <- board_rsconnect()
b %>% pin_write(tidy_sales_data, "sales-summary")
#> Saving to hadley/sales-summary
And then someone else (or an automated Rmd report) can read it:
b <- board_rsconnect()
b %>% pin_read("hadley/sales-summary")
You can easily control who gets to see it using the RStudio Connection permissions pane.
As well as RStudio connect, you can share your pins:
- In shared folders:
board_folder()
. - On GitHub:
board_github()
. - In Microsoft Azure’s storage:
board_azure()
. - On Amazon’s S3:
board_s3()
.