|
| 1 | +Getting Started |
| 2 | +=============== |
| 3 | + |
| 4 | +The pins package helps you publish data sets, models, and other R objects, making it easy to share them across projects and with your colleagues. |
| 5 | +You can pin objects to a variety of "boards", including local folders (to share on a networked drive or with dropbox), RStudio connect, Amazon S3, and more. |
| 6 | +This vignette will introduce you to the basics of pins. |
| 7 | + |
| 8 | +```{python} |
| 9 | +import pins |
| 10 | +``` |
| 11 | + |
| 12 | +## Getting started |
| 13 | + |
| 14 | +Every pin lives in a pin *board*, so you must start by creating a pin board. |
| 15 | +In this vignette I'll use a temporary board which is automatically deleted when your R session is over: |
| 16 | + |
| 17 | +```{python} |
| 18 | +# TODO: simple board constructors |
| 19 | +import fsspec |
| 20 | +import tempfile |
| 21 | +
|
| 22 | +fs = fsspec.filesystem("file") |
| 23 | +tmp_dir = tempfile.TemporaryDirectory() |
| 24 | +
|
| 25 | +board = pins.BaseBoard(tmp_dir.name, fs) |
| 26 | +``` |
| 27 | + |
| 28 | +In real-life, you'd pick a board depending on how you want to share the data. |
| 29 | +Here are a few options: |
| 30 | + |
| 31 | +```{python} |
| 32 | +# TODO |
| 33 | +# board <- board_local() # share data across R sessions on the same computer |
| 34 | +# board <- board_folder("~/Dropbox") # share data with others using dropbox |
| 35 | +# board <- board_folder("Z:\\my-team\pins") # share data using a shared network drive |
| 36 | +# board <- board_rsconnect() # share data with RStudio Connect |
| 37 | +``` |
| 38 | + |
| 39 | +## Reading and writing data |
| 40 | + |
| 41 | +Once you have a pin board, you can write data to it with `pin_write()`: |
| 42 | + |
| 43 | +```{python} |
| 44 | +from siuba.data import mtcars |
| 45 | +board.pin_write(mtcars, "mtcars", type="csv") |
| 46 | +``` |
| 47 | + |
| 48 | +The first argument is the object to save (usually a data frame, but it can be any R object), and the second argument gives the "name" of the pin. |
| 49 | +The name is basically equivalent to a file name: you'll use it when you later want to read the data from the pin. |
| 50 | +The only rule for a pin name is that it can't contain slashes. |
0 commit comments