You can use the
pins package to:
There are two main ways pin a resource:
Pin a remote file with
pin(url). This will download the file and make it available in a local cache:
Pin an expensive local computation with
Then later retrieve it with
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:
pin_find("seattle", board = "packages") #> # A tibble: 4 x 4 #> name description type board #> <chr> <chr> <chr> <chr> #> 1 hpiR/seattle_sales Boston Housing Prices from hpiR pa… table packag… #> 2 microsynth/seattledmi Boston Housing Prices from microsy… table packag… #> 3 vegawidget/data_seattl… Boston Housing Prices from vegawid… table packag… #> 4 vegawidget/data_seattl… Boston Housing Prices from vegawid… table packag…
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
sales <- pin_get("hpiR/seattle_sales") head(sales) #> # A tibble: 6 x 16 #> pinx sale_id sale_price sale_date use_type area lot_sf wfnt #> <chr> <chr> <int> <date> <chr> <int> <int> <dbl> #> 1 ..00… 2013..… 289000 2013-02-06 sfr 79 9295 0 #> 2 ..00… 2013..… 356000 2013-07-11 sfr 18 6000 0 #> 3 ..00… 2010..… 333500 2010-12-29 sfr 79 7200 0 #> 4 ..00… 2016..… 577200 2016-03-17 sfr 79 7200 0 #> 5 ..00… 2012..… 237000 2012-05-02 sfr 79 5662 0 #> 6 ..00… 2014..… 347500 2014-03-11 sfr 79 5830 0 #> # … with 8 more variables: bldg_grade <int>, tot_sf <int>, beds <int>, #> # baths <dbl>, age <int>, eff_age <int>, longitude <dbl>, latitude <dbl>
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
To publish to Kaggle, you would first need to register the Kaggle board by creating a Kaggle API Token:
You can then easily publish to Kaggle:
Learn more in
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.
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:
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!
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.