Learn R Programming

pins

The pins package publishes data, models, and other R objects, making it easy to share them across projects and with your colleagues. You can pin objects to a variety of pin boards, including folders (to share on a networked drive or with services like DropBox), Posit Connect, Amazon S3, Google Cloud Storage, Azure storage, and Microsoft 365 (OneDrive and SharePoint). Pins can be automatically versioned, making it straightforward to track changes, re-run analyses on historical data, and undo mistakes.

pins 1.0.0 includes a new more explicit API and greater support for versioning. The legacy API (pin(), pin_get(), and board_register()) will continue to work, but new features will only be implemented with the new API, so we encourage you to switch to the modern API as quickly as possible. Learn more in vignette("pins-update").

You can use pins from Python as well as R. For example, you can use one language to read a pin created with the other. Learn more about pins for Python.

Installation

You can install pins from CRAN with:

install.packages("pins")

You can install the development version from GitHub:

# install.packages("pak")
pak::pak("rstudio/pins-r")

Usage

To use the pins package, you must first create a pin board. A good place to start is board_folder(), which stores pins in a directory you specify. Here I’ll use a special version of board_folder() called board_temp() which creates a temporary board that’s automatically deleted when your R session ends. This is great for examples, but obviously you shouldn’t use it for real work!

library(pins)

board <- board_temp()
board
#> Pin board <pins_board_folder>
#> Path:
#> '/var/folders/07/0sps_qnd3qd7fdj3cq9j8pqw0000gn/T/RtmpfnLq46/pins-16f285b5dde39'
#> Cache size: 0

You can “pin” (save) data to a board with pin_write(). It takes three arguments: the board to pin to, an object, and a name:

board %>% pin_write(head(mtcars), "mtcars")
#> Guessing `type = 'rds'`
#> Creating new version '20230816T005558Z-8df40'
#> Writing to pin 'mtcars'

As you can see, the data saved as an .rds by default, but depending on what you’re saving and who else you want to read it, you might use the type argument to instead save it as a Parquet, Arrow, CSV, or JSON file.

You can later retrieve the pinned data with pin_read():

board %>% 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

A board on your computer is good place to start, but the real power of pins comes when you use a board that’s shared with multiple people. To get started, you can use board_folder() with a directory on a shared drive or in dropbox, or if you use Posit Connect you can use board_connect():

board <- board_connect()
#> Connecting to Posit Connect 2023.01.0 at <https://colorado.posit.co/rsc>
board %>% pin_write(tidy_sales_data, "sales-summary", type = "rds")
#> Writing to pin 'hadley/sales-summary'

Then, someone else (or an automated Rmd report) can read and use your pin:

board <- board_connect()
board %>% pin_read("hadley/sales-summary")

You can easily control who gets to access the data using the Posit Connect permissions pane.

The pins package also includes boards that allow you to share data on services like Amazon’s S3 (board_s3()), Azure’s blob storage (board_azure()), and Google Cloud Storage (board_gcs()). Learn more in vignette("pins").

Copy Link

Version

Install

install.packages('pins')

Monthly Downloads

4,843

Version

1.2.1

License

Apache License (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Julia Silge

Last Published

August 16th, 2023

Functions in pins (1.2.1)

legacy_azure

Azure board (legacy API)
pin_default_name

Create Pin Name
pin_browse

Browse source of a pin
pin

Pin a resource (legacy API)
legacy_dospace

DigitalOcean board (legacy API)
board_url

Use a vector of URLs as a board
legacy_local

Local board (legacy API)
pin_meta

Retrieve metadata for a pin
board_test

Test Board
pin_find

Search for pins (legacy API)
legacy_gcloud

Google Cloud board (legacy API)
pin_fetch

Fetch/store a pin
legacy_kaggle

Kaggle board (legacy API)
legacy_s3

S3 board (legacy API)
new_board

Create a new board
pin_read

Read and write objects to and from a board
pin_remove

Delete a pin (legacy API)
pin_info

Retrieve pin metadata (legacy API)
pin_delete

Delete a pin
pin_get

Retrieve a pin (legacy API)
pins-package

pins: Pin, Discover and Share Resources
reexports

Objects exported from other packages
pin_download

Upload and download files to and from a board
pin_preview

Preview a pin (legacy API)
write_board_manifest_yaml

Write a manifest YAML file for a board
required_pkgs.pins_board_azure

Determine required packages for a pins board
pin_list

List all pins
legacy_github

GitHub board (legacy API)
pin_search

Search for pins
pin_log

Pin Logging
pin_exists

Determine if a pin exists
pin_versions

List, delete, and prune pin versions
pin_reactive

Reactive Pin (legacy API)
pin_reactive_read

Wrap a pin in a reactive expression
write_board_manifest

Write board manifest file to board's root directory
board_gdrive

Use a Google Drive folder as a board
board_connect

Use Posit Connect as board
board_ms365

Use a OneDrive or Sharepoint document library as a board
board_gcs

Use a Google Cloud Storage bucket as a board
board_deparse

Deparse a board object
board_folder

Use a local folder as board
board_azure

Use an Azure storage container as a board
board_connect_url

Use a vector of Posit Connect vanity URLs as a board
board_cache_path

Retrieve default cache path
legacy_datatxt

Remote "data.txt" board (legacy API)
cache_browse

Cache management
board_kaggle

Use kaggle datasets/competitions as a board
board_register

Board registry (legacy API)
pin_load

Custom Pins
board_pin_create

Custom Boards
board_s3

Use an S3 bucket as a board