Overview

You can use the pins package to:

  • Pin remote resources locally with pin(), work offline and cache results.
  • Discover new resources across different boards using pin_find().
  • Share resources in local folders, GitHub, Kaggle, and RStudio Connect by registering new boards with board_register().

Usage

library(pins)

Pin

There are two main ways pin a resource:

Discover

You can also discover remote resources using pin_find(). It can search for resources in CRAN packages, Kaggle, and RStudio Connect. For instance, we can search datasets mentioning “seattle” in CRAN packages with:

Notice that the full name of a pin is <owner>/<name>. This namespacing allows multiple people (or packages) to create pins with the same name.

You can then retrieve a pin through pin_get():

Share

Finally, you can share resources with other R sessions and other users by publishing to a local folder, Kaggle, GitHub and RStudio Connect. To share with other R sessions, you can use a local board which stores pins in a shared path, usually ~/.pins:

board_register_local(cache = "~/pins")

To publish to Kaggle, you would first need to register the Kaggle board by creating a Kaggle API Token:

board_register_kaggle(token = "<path-to-kaggle.json>")

You can then easily publish to Kaggle:

pin(sales, name = "seattle_sales", board = "kaggle")

Learn more in vignette("boards-understanding")

RStudio

Experimental support for pins was introduced in RStudio Connect 1.7.8 so that you can use RStudio and RStudio Connect to discover and share resources within your organization with ease. To enable new boards, use RStudio’s Data Connections to start a new ‘pins’ connection and then select which board to connect to:

Once connected, you can use the connections pane to track the pins you own and preview them with ease. Notice that one connection is created for each board.

To discover remote resources, simply expand the “Addins” menu and select “Find Pin” from the dropdown. This addin allows you to search for pins across all boards, or scope your search to particular ones as well:

You can then share local resources using the RStudio Connect board. Lets use dplyr and the hpiR_seattle_sales pin to analyze this further and then pin our results in RStudio Connect.

board_register_rsconnect(name = "myrsc")

After a pin is published, you can then browse to the pin’s content from the RStudio Connect web interface.

You can now set the appropriate permissions in RStudio Connect, and voila! From now on, those with access can make use of this remote file locally!

For instance, a colleague can reuse the sales-by-baths pin by retrieving it from RStudio Connect and visualize its contents using ggplot2:

library(ggplot2)
board_register_rsconnect(name = "myrsc")

pin_get("sales-by-baths", board = "myrsc") %>%
  ggplot(aes(x = baths, y = sale)) +
  geom_point() + 
  geom_smooth(method = 'lm', formula = y ~ exp(x))

Pins can also be automated using scheduled R Markdown. This makes it much easier to create Shiny applications that rely on scheduled data updates or to share prepared resources across multiple pieces of content. You no longer have to fuss with file paths on RStudio Connect, mysterious resource URLs, or redeploying application code just to update a dataset!

Python

Experimental support for pins is also available in Python. However, since the Python interface currently makes use of the R package, the R runtime needs to be installed when using pins from Python. To get started, first install the pins module:

Followed by using pins from Python:

Please make sure to pin visit, rstudio.github.io/pins, where you will find detailed documentation and additional resources.