From 345a36b4e2706f0e7de81bc590cf1404a532e29d Mon Sep 17 00:00:00 2001
From: juliasilge Instead, we can also write a special function for reading, to
reconstruct the factor including its levels: Reading from the downloaded pin is straightforward;
A function to store factors
ten_letters <- factor(sample(letters, size = 10), levels = letters)
board %>% pin_write_factor_json(ten_letters, "letters-as-json")
-#> Creating new version '20240108T164405Z-9d061'
+#> Creating new version '20240108T172501Z-c5c22'
#> Writing to pin 'letters-as-json'
A function to read factors
@@ -170,7 +170,7 @@
A function to read factors
+#> [1] "d" "j" "p" "t" "m" "o" "e" "h" "k" "x"
@@ -181,7 +181,7 @@
A function to read factors}
board %>% pin_read_factor_json("letters-as-json")
-#> [1] l j c h o u q w k y
+#> [1] d j p t m o e h k x
#> Levels: a b c d e f g h i j k l m n o p q r s t u v w x y z
Upload a single filearrow::write_feather(mtcars, path, compression = "uncompressed")
pin_upload(board, paths = path, name = pin_name)
-#> Creating new version '20240108T164408Z-0128c'
pin_download()
returns a local path that can be piped to
arrow::read_feather()
:Function to manage uploadingpin_write():
pin_upload_arrow(board, x = mtcars, name = "mtcars-arrow2")
-#> Creating new version '20240108T164408Z-0128c'
As before, you can pipe the result of pin_download()
to
your reader function:
diff --git a/dev/articles/pins-update.html b/dev/articles/pins-update.html index 4b8a98e4..0ad4a663 100644 --- a/dev/articles/pins-update.html +++ b/dev/articles/pins-update.html @@ -148,7 +148,7 @@Examples pin_write(board, head(mtcars), "mtcars") #> Guessing `type = 'rds'` -#> Creating new version '20240108T164412Z-0a03e' +#> Creating new version '20240108T172507Z-0a03e' #> Writing to pin 'mtcars' pin_read(board, "mtcars") #> mpg cyl disp hp drat wt qsec vs am gear carb @@ -187,7 +187,7 @@
Pinning filespin(path, "alphabet", board = "vignette") pin_get("alphabet", board = "vignette") -#> [1] "/tmp/RtmpiwX0A0/file20f05f7fc1bc/alphabet/file20f03a5d168d"
pins 1.0.0 clearly separates the two cases of pin an object and
pinning a file, so here instead of pin_write()
and
pin_read()
you need to pin_upload()
and
@@ -195,9 +195,9 @@
# Modern API
board %>% pin_upload(path, "alphabet")
-#> Creating new version '20240108T164413Z-ee580'
+#> Creating new version '20240108T172509Z-ee580'
board %>% pin_download("alphabet")
-#> [1] "~/.local/share/pins/alphabet/20240108T164413Z-ee580/file20f03a5d168d"
+#> [1] "~/.local/share/pins/alphabet/20240108T172509Z-ee580/file200159c29086"
This now needs to be made explicit with the new
board_url()
, and since this returns a path, not a file, you
need to use pin_download()
:
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 @@ -168,7 +168,7 @@
You don’t need to supply the file type when reading data from a pin -because pins automatically stores the file type in the metadata.
+because pins automatically stores the file type in the metadata.This shows you the metadata that’s generated by default. This includes:
While we’ll do our best to keep the automatically generated metadata
consistent over time, I’d recommend manually capturing anything you
really care about in metadata
.
You can list all the available versions with
pin_versions()
:
You can delete a specific older version with
pin_version_delete()
or sets of older versions with
pin_versions_prune()
.
board %>% pin_upload(paths, "example")
-#> Creating new version '20240108T164418Z-e9d42'
pin_download()
returns a vector of paths:
board %>% pin_download("example")
-#> [1] "/tmp/RtmpyBszyl/pins-213c1274221e/example/20240108T164418Z-e9d42/mtcars.csv"
-#> [2] "/tmp/RtmpyBszyl/pins-213c1274221e/example/20240108T164418Z-e9d42/alphabet.txt"
It’s now your job to handle them. You should treat these paths as internal implementation details — never modify them and never save them for use outside of pins.
@@ -399,7 +399,7 @@
board %>% pin_download("mtcars")
-#> [1] "/tmp/RtmpyBszyl/pins-213c1274221e/mtcars/20240108T164416Z-7c7a6/mtcars.rds"
board %>% pin_write(mtcars, type = "json")
#> Using `name = 'mtcars'`
-#> Creating new version '20240108T164426Z-c2702'
+#> Creating new version '20240108T172523Z-c2702'
#> Writing to pin 'mtcars'
Let’s make a new version of this data by adding a column:
lper100km
, consumption in liters per 100 km. This could
@@ -161,7 +161,7 @@
Let’s check our board to ensure we have one pin named
"mtcars"
, with two versions:
Because a board_url()
is consumed over the web, it
doesn’t have access to a file system the way, for example, a
board_folder()
has; we can work around this by creating a
@@ -199,8 +199,8 @@
mtcars:
-- mtcars/20240108T164426Z-c2702/
-- mtcars/20240108T164428Z-8416c/
+- mtcars/20240108T172523Z-c2702/
+- mtcars/20240108T172525Z-8416c/
At this point, we would publish the folder containing the board as a
part of a web site. Let’s pretend that we have served the folder from
our fake website, https://not.real.website.co/pins/
.
We can read the most-recent version of the "mtcars"
pin:
diff --git a/dev/favicon-16x16.png b/dev/favicon-16x16.png index 698907387251bcec575f9cd0de70570f539b3309..ecaadad3cf1aa6feef3b963620225cb060c4aa66 100644 GIT binary patch delta 64 zcmey%`ImEpBs069ghE!E^Rdke%sPyM=2k`~R>nr!1_o9J1~KYPyC%o7D4>e!R_$V& I+{cm+05HoC%K!iX delta 64 zcmey%`ImEpBs05!wmPHt&7{o=%sPyMW>zM~R>qdv1_o9J2A%ig{!fl&Q9u>_(e%uD Iavw`R090!eLI3~& diff --git a/dev/favicon-32x32.png b/dev/favicon-32x32.png index 2fd56659827cedf59681db210624f93babb81df6..de8e0bbdbc608b2734ac7a1e962fec61c769ea8e 100644 GIT binary patch delta 62 zcmbQhKY@QjHM^jMqHJSvz{aLnHbHYMBNHoQV{HQiD+7aH0i1l3Kd>pFigxpE+%#E{ GJs$uVLlGMQ delta 62 zcmbQhKY@QjHM@Ye#>6j2K5uM_WfL^BGBLI?G0-+Jure?ZYZ5Y@{DDmYRW$wns?N!Z G?D+t0NfQSE diff --git a/dev/pkgdown.yml b/dev/pkgdown.yml index 76ca4a3f..fcf651bf 100644 --- a/dev/pkgdown.yml +++ b/dev/pkgdown.yml @@ -8,7 +8,7 @@ articles: pins: pins.html posit-connect: posit-connect.html using-board-url: using-board-url.html -last_built: 2024-01-08T16:43Z +last_built: 2024-01-08T17:24Z urls: reference: https://pins.rstudio.com/reference article: https://pins.rstudio.com/articles diff --git a/dev/reference/board_register.html b/dev/reference/board_register.html index aab362b9..f1ab147e 100644 --- a/dev/reference/board_register.html +++ b/dev/reference/board_register.html @@ -147,7 +147,7 @@Examplesboard %>% pin_write(mtcars) #> Using `name = 'mtcars'` #> Guessing `type = 'rds'` -#> Creating new version '20240108T164352Z-b755f' +#> Creating new version '20240108T172447Z-b755f' #> Writing to pin 'mtcars' board %>% pin_read("mtcars") #> mpg cyl disp hp drat wt qsec vs am gear carb diff --git a/dev/reference/legacy_local.html b/dev/reference/legacy_local.html index 59da7d5e..a12fc2dc 100644 --- a/dev/reference/legacy_local.html +++ b/dev/reference/legacy_local.html @@ -142,7 +142,7 @@
Examplesboard <- board_local() board %>% pin_write(data.frame(x = 1:3), "test") #> Guessing `type = 'rds'` -#> Creating new version '20240108T164355Z-d376d' +#> Creating new version '20240108T172450Z-d376d' #> Writing to pin 'test' board %>% pin_read("test") #> x diff --git a/dev/reference/pin.html b/dev/reference/pin.html index feeb3209..0f228ce5 100644 --- a/dev/reference/pin.html +++ b/dev/reference/pin.html @@ -163,7 +163,7 @@
Examplesboard %>% pin_write(mtcars) #> Using `name = 'mtcars'` #> Guessing `type = 'rds'` -#> Creating new version '20240108T164356Z-b755f' +#> Creating new version '20240108T172451Z-b755f' #> Writing to pin 'mtcars' board %>% pin_read("mtcars") #> mpg cyl disp hp drat wt qsec vs am gear carb diff --git a/dev/reference/pin_browse.html b/dev/reference/pin_browse.html index 13ac0a8f..5b1ce501 100644 --- a/dev/reference/pin_browse.html +++ b/dev/reference/pin_browse.html @@ -110,19 +110,19 @@
Examples
board <- board_temp(versioned = TRUE) board %>% pin_write(1:10, "x") #> Guessing `type = 'rds'` -#> Creating new version '20240108T164356Z-709c5' +#> Creating new version '20240108T172451Z-709c5' #> Writing to pin 'x' board %>% pin_write(1:11, "x") #> Guessing `type = 'rds'` -#> Creating new version '20240108T164356Z-f6f8c' +#> Creating new version '20240108T172451Z-f6f8c' #> Writing to pin 'x' board %>% pin_write(1:12, "x") #> Guessing `type = 'rds'` -#> Creating new version '20240108T164356Z-94347' +#> Creating new version '20240108T172451Z-94347' #> Writing to pin 'x' board %>% pin_browse("x", local = TRUE) -#> ℹ Pin at </tmp/RtmpJ5rjTd/pins-18fd3bbfe850/x/20240108T164356Z-f6f8c> +#> ℹ Pin at </tmp/RtmpQOlTqP/pins-180d4d8f0df6/x/20240108T172451Z-f6f8c>