0

I'm getting a namespace error when I run the code below as follows: Warning: Error in : 'zipr' is not an exported object from 'namespace:zip' [No stack trace available]. Any suggestions on what this could be due to? Thanks in advance.

library(shiny)
library(ggplot2)

ui <- fluidPage(
  plotOutput("p1"), 
  plotOutput("p2"),
  plotOutput("p3"),
  downloadButton("allgraphs", "Download")
)

server = function(input, output) {
  df<-data.frame(q=c(1,3,5,7,9),w=c(2,4,6,8,10),z=c(1,2,3,4,5))

  p1 <- reactive({
    ggplot(df,aes(x=q,y=w)) + geom_point()
  })
  p2 <- reactive({
    ggplot(df,aes(x=z,y=w))+geom_point()
  })
  p3 <- reactive({
    ggplot(df,aes(x=q,y=z))+geom_point()
  })

  output$p1 <- renderPlot({ 
    p1()
  })
  output$p2 <- renderPlot({ 
    p2()
  })
  output$p3 <- renderPlot({ 
    p3()
  })

  output$allgraphs = downloadHandler(
    filename = function() {
      'all_images.zip'
    }, 
    content = function(fname) {
      fs <- replicate(3, tempfile(fileext = ".png"))
      ggsave(fs[1], p1())
      ggsave(fs[2], p2())
      ggsave(fs[3], p3())
      zip::zipr(zipfile=fname, files=fs)
    },
    contentType = "application/zip")
}

shinyApp(ui, server)

piper180
  • 329
  • 2
  • 12
  • 2
    ava, unfortunately I cannot reproduce your error (the above shiny app worked without error). For perspective, I'm in win10, R-4.0.1, zip-2.0.4, ggplot2-3.3.0, shiny-1.4.0.2. While distasteful to me, have you tried restarting R to see if it's a transient error? – r2evans Jun 26 '20 at 16:35
  • 1
    I see -- yes, I've tried restarting R and checking for package updates. Still no luck unfortunately. – piper180 Jun 26 '20 at 17:16
  • 1
    It might be useful/informative to include your R and package version information, in case it's a new regression or something fixed in a recent update. – r2evans Jun 26 '20 at 18:33

1 Answers1

0

You need to update your zip package to latest version. I had the same issue with version 1.0.0 of zip which doesn't exports any zipR object and openxlsx loading would fail. The upgrade of zip to v2.1.0, which indeed exports a zipR object, solved the issue.

rBw77
  • 11
  • 3