Hi @CMT,
Sorry that solution didn't work for you. On the speed issue -- one reason it may be so fast with pins
is that pins
actually caches a local version of something it's downloaded before. This means that downloads after the first are likely to be relatively fast, but first downloads are probably going to be similar. Unfortunately, none of these solutions are able to take advantage of the caching, so they'll all be that "first time download" slow every time.
Two other things to try below. Hopefully one of these will work...even if speed isn't ideal...
Using Pins
[EDIT]: @CMT has suggested this is best option and that the name has to be set for each piece of content separately.
pins::pin("https://colorado.rstudio.com/rsc/bike_rxgb/data.rds", extract = FALSE, name = "rxgb") %>% readRDS()
(Not a typo to use pins::pin
instead of the expected pin_get
)
Using httr
Here's a little function I wrote using httr
:
#' Get a pin by the vanity URL
#' @param vanity_url the url of the pin on RSC
#' @param outfile a file to write to (could be tempfile())
#' @return none, loads file
#' @examples
#' read_rds_pin("https://colorado.rstudio.com/rsc/bike_rxgb/", tempfile()))
read_rds_pin <- function(vanity_url, outfile) {
outfile_str <- outfile
outfile <- file(outfile, "wb")
writeBin(httr::content(httr::GET(file.path(vanity_url, "data.rds"))),
outfile)
close(outfile)
readRDS(outfile_str)
}
Hopefully one of them will work for you...
In my testing, all 3 of these options took roughly the same amount of time...maybe a slight advantage to the pins
version.
> system.time(lapply(1:10, function(x) read_rds_pin("https://colorado.rstudio.com/rsc/bike_rxgb/", tempfile())))/10
user system elapsed
3.1178 0.1735 3.9468
> system.time(lapply(1:10, function(x) {pins::pin("https://colorado.rstudio.com/rsc/bike_rxgb/data.rds", extract = FALSE) %>% readRDS()}))/10
user system elapsed
2.8602 0.1785 3.0615
> system.time(lapply(1:10, function(x) {file_path <- tempfile()
+ download.file("https://colorado.rstudio.com/rsc/bike_rxgb/data.rds",
+ file_path)
+ readRDS(file_path)}))/10
user system elapsed
3.0960 0.1962 3.9921
Hopefully one of these will work for you.
In terms of timing, I don't have a timeline, but the git issue on the pins
package will be your best bet for updates.