From 66ea0c2ec6afedc710b2d1ecbca022ac6a84348a 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;
ten_letters <- factor(sample(letters, size = 10), levels = letters)
board %>% pin_write_factor_json(ten_letters, "letters-as-json")
-#> Creating new version '20231120T174337Z-de12b'
+#> Creating new version '20231120T190243Z-583c9'
#> Writing to pin 'letters-as-json'
A function to read factors
@@ -170,7 +170,7 @@
A function to read factors
+#> [1] "q" "l" "r" "t" "w" "j" "c" "a" "p" "v"
@@ -181,7 +181,7 @@
A function to read factors}
board %>% pin_read_factor_json("letters-as-json")
-#> [1] a f n w m p r o g h
+#> [1] q l r t w j c a p v
#> 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 '20231120T174339Z-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 '20231120T174339Z-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 b14ca191..1d51f1f4 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 '20231120T174343Z-0a03e' +#> Creating new version '20231120T190249Z-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/RtmpwsQEZN/file212921fa4a40/alphabet/file21297695e48f"
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 '20231120T174344Z-ee580'
+#> Creating new version '20231120T190251Z-ee580'
board %>% pin_download("alphabet")
-#> [1] "~/.local/share/pins/alphabet/20231120T174344Z-ee580/file21297695e48f"
+#> [1] "~/.local/share/pins/alphabet/20231120T190251Z-ee580/file202217924b72"
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 @@ -226,14 +226,14 @@
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 '20231120T174349Z-e9d42'
pin_download()
returns a vector of paths:
board %>% pin_download("example")
-#> [1] "/tmp/RtmpPrcjNv/pins-21755aedca20/example/20231120T174349Z-e9d42/mtcars.csv"
-#> [2] "/tmp/RtmpPrcjNv/pins-21755aedca20/example/20231120T174349Z-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.
@@ -384,7 +384,7 @@
board %>% pin_download("mtcars")
-#> [1] "/tmp/RtmpPrcjNv/pins-21755aedca20/mtcars/20231120T174347Z-7c7a6/mtcars.rds"
board %>% pin_write(mtcars, type = "json")
#> Using `name = 'mtcars'`
-#> Creating new version '20231120T174359Z-c2702'
+#> Creating new version '20231120T190305Z-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/20231120T174359Z-c2702/
-- mtcars/20231120T174401Z-8416c/
+- mtcars/20231120T190305Z-c2702/
+- mtcars/20231120T190308Z-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 5d73827571e6f59bc2d7c89a8d885821247c6d5c..fb38ac228ad385061b448495043028e5b063c62d 100644 GIT binary patch delta 64 zcmey%`ImEpBs04(6R+*f;?T_s%sPyMmR1HvR))sf1_o9J1{(?vo}L`bqJS!TP`9#t Iavw`R08Zo*X8-^I delta 64 zcmey%`ImEpBs069HfL?wpOc#vm~|Kh&8#3#qHD4>e+a2c(h I+{cm+09qUoQUCw| diff --git a/dev/favicon-32x32.png b/dev/favicon-32x32.png index 8caea9a7e0d36261c35a7a6c05558c361d046508..5246fd911f158efe1af2274afd0facfb5941d0e3 100644 GIT binary patch delta 62 zcmbQhKY@QjHM=kq-;xVT?>9EZvI$yR85mg^nrIssSQ!|UUjOep`2(8*swhjB`_IXW G?D+s^#1j+% delta 62 zcmbQhKY@QjHM^iT*OU6S#T%Pq*#yn4OpL7z4YUmmtPBiPQqM Releases Source: NEWS.md
CRAN release: 2023-11-09
board <- board_temp(versioned = TRUE)
board %>% pin_write(1:10, "x")
#> Guessing `type = 'rds'`
-#> Creating new version '20231120T174327Z-709c5'
+#> Creating new version '20231120T190232Z-709c5'
#> Writing to pin 'x'
board %>% pin_write(1:11, "x")
#> Guessing `type = 'rds'`
-#> Creating new version '20231120T174327Z-f6f8c'
+#> Creating new version '20231120T190232Z-f6f8c'
#> Writing to pin 'x'
board %>% pin_write(1:12, "x")
#> Guessing `type = 'rds'`
-#> Creating new version '20231120T174327Z-94347'
+#> Creating new version '20231120T190232Z-94347'
#> Writing to pin 'x'
board %>% pin_browse("x", local = TRUE)
-#> ℹ Pin at </tmp/RtmpprwnN7/pins-193748a12e7f/x/20231120T174327Z-f6f8c>
+#> ℹ Pin at </tmp/RtmpKGnmZU/pins-182351de74eb/x/20231120T190232Z-f6f8c>