-
Notifications
You must be signed in to change notification settings - Fork 62
/
README.Rmd
101 lines (73 loc) · 3.93 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
---
output:
github_document:
fig_width: 8
fig_height: 4
---
```{r, echo=FALSE, message=FALSE}
knitr::opts_chunk$set(
fig.path = "tools/readme/",
dev = "png",
dpi = 96,
comment = "#>",
collapse = TRUE
)
```
# pins [<img src="man/figures/logo.png" align="right" height="139"/>](https://pins.rstudio.com)
<!-- badges: start -->
[![R-CMD-check](https://github.com/rstudio/pins-r/workflows/R-CMD-check/badge.svg)](https://github.com/rstudio/pins-r/actions)
[![CRAN Status](https://www.r-pkg.org/badges/version/pins)](https://cran.r-project.org/package=pins)
[![Codecov test coverage](https://codecov.io/gh/rstudio/pins-r/branch/main/graph/badge.svg)](https://app.codecov.io/gh/rstudio/pins-r?branch=main)
<!-- badges: end -->
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, 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](https://rstudio.github.io/pins-python/).
## Installation
You can install pins from CRAN with:
```{r, eval = FALSE}
install.packages("pins")
```
You can install the development version from GitHub:
```{r, eval = FALSE}
remotes::install_github("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!
```{r setup}
library(pins)
board <- board_temp()
board
```
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:
```{r}
board %>% pin_write(head(mtcars), "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 `csv`, `json`, or `arrow` file.
You can later retrieve the pinned data with `pin_read()`:
```{r}
board %>% pin_read("mtcars")
```
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](https://posit.co/products/enterprise/connect/) you can use `board_connect()`:
```{r, eval = FALSE}
board <- board_connect()
#> Connecting to RSC 1.9.0.1 at <https://connect.rstudioservices.com>
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:
```{r, eval = FALSE}
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 Microsoft SharePoint (`board_ms365()`).
Learn more in `vignette("pins")`.