Skip to content

Pins#

The pins R package provides a way for R users to easily share data using RStudio Connect. Your resources may be text files (CSV, JSON, etc.), R objects (.Rds, .Rda, etc.) or any other format you use to share data. Sharing data can be useful in many situations, for example:

  1. Multiple pieces of content require the same input data. Rather than copying that data, each piece of content references a single source of truth hosted on RStudio Connect.

  2. Content depends on data or model objects that need to be regularly updated. Rather than redeploying the content each time the data changes, use a pinned resource and update only the data. The data update can occur using a scheduled R Markdown document. Your content will read the newest data on each run.

  3. You need to share resources that aren't structured for traditional tools like databases. For example, models saved as R objects aren't easy to store in a database. Rather than using email or file systems to share data files, use RStudio Connect to host these resources as pins.

Pins and large data sets

An important factor in determining whether or not to use a pin is the size of the data or object in use. You can learn more about using pins with larger data sets in the article "Too Big To Pin".

Deploying a Pin#

Deploying a Pin from RStudio#

To deploy a pin from RStudio, first follow the steps to link RStudio to Connect.

Once complete, you can deploy a pin using the package's board_register_rsconnect and pin functions:

board_register_rsconnect(server = "https://connect.example.com")
iris %>%
  filter(Species == "Setosa") %>%
  pin("s_iris", board = "rsconnect")

Deploying a Pin from R code#

You may wish to deploy a pin from outside of RStudio. For example, you can write a R Markdown document that deploys a pin. That R Markdown document is deployed to RStudio Connect and run on a schedule. In this case, you must use an API key when you register the board. The code inside your R Markdown document might look like:

connectAPIKey <- Sys.getenv("CONNECT_API_KEY")

board_register_rsconnect(server = "https://connect.example.com", key = connectAPIKey)

iris %>%
  filter(Species == "Setosa") %>%
  pin("s_iris", board = "rsconnect")

This code obtains the API key from an environment variable before supplying that key to board_register_rsconnect. The API Keys from Code section contains additional examples that use API keys from code.

Using a Pin#

Once a pin has been deployed, it is easy to share the pin with colleagues. You can either share the link to the pin in RStudio Connect, or colleagues can search for resources using the pin package within RStudio.

board_register_rsconnect(server = "https://connect.example.com")
pin_get("s_iris", board = "rsconnect")

If your pin has restricted access and you want to access that pin from other content deployed to RStudio Connect, use an API key. A Shiny application, for example, uses the API key authenticate its pin access.

connectAPIKey <- Sys.getenv("CONNECT_API_KEY")

board_register_rsconnect(server = "https://connect.example.com", key = connectAPIKey)

pin_get("s_iris", board = "rsconnect")

The API Keys from Code section contains additional examples that use API keys from code.

Learn more about using pins on RStudio Connect.

Pin Settings#

You can manage content settings for deployed pins just like you would for other content types. For example, you can manage access controls to pins to determine who should be able to view and utilize the resource. You can also add more information about your pin, and track the number of times the pin has been requested.