Pin .zip-files to RStudio Connect

Hi everyone

I'm looking for a way to pin multiple documents to RStudio Connect as one zip file. I've learned that as from pins version 0.4.1 this option was added (see also

Does anyone has done this before? In what class the objects have to be transferred to the pin-function?

What I've tried:

# create random files 
testframe <- data.frame(a = c(1, 2, 3), b = c(1, 2, 3))
testframe2 <- data.frame(a = c(1, 2, 3, 4, 5), b = c(1, 2, 3, 4, 5))                
testplot <- ggplot2::ggplot(data = testframe, ggplot2::aes(x=a, y=b)) +
testplot2 <- ggplot2::ggplot(data = testframe2, ggplot2::aes(x=a, y=b)) +

# create object containing objects to be pinned as one zip file
object_to_pin <- list(testframe=testframe, testframe2=testframe2, testplot=testplot, testplot2=testplot2)

# pin to Connect
pins::pin(x = object_to_pin , name = "Test", board = "rsconnect", zip = TRUE)

This code gives me the Error:

Error in gzfile(file, "rb") : cannot open the connection
In addition: Warning message:
In gzfile(file, "rb") :
cannot open compressed file '/home/USER/.cache/pins/rsconnect/USER/Test/data.rds', probable reason 'No such file or directory'

The zip parameter is only supported when creating pins from files paths, not objects.

Please try removing zip = TRUE since the pins package already supports uploading object_to_pin without any additional work.

Thanks a lot for the advice Javier. I zipped the objects to and ran

pins::pin(x = "...path.../", name = "Test", board = "rsconnect")

which worked.

That also works, but unless you need the original files to be opened outside of R, you could also skip the zip creation entirely. The pins package is able to store any R object, including a list of ggplots. Perhaps your application does require files and a zip, but other users of pins should just pin the R objects without manually creating a zip file.

Anyways, glad you found a workaround!

That's good to know. Thank you Javier.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.