When running the following shiny app from the console with runApp(), it works as expected, displaying a plot and providing the ability to download an excel file with the plot embedded. Running the same app on shiny-server, yields the error
cannot open file 'Rplots.pdf'
- Shiny Server v1.4.2.786
- Node.js v0.10.40
- R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Ubuntu 14.04.4 LTS
library(shiny) library(openxlsx) library(magrittr) # Define UI for application that draws a histogram ui <- shinyUI(fluidPage( # Application title titlePanel("Old Faithful Geyser Data"), # Sidebar with a slider input for number of bins sidebarLayout( sidebarPanel( sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30), downloadButton('specDataDownload', label = "Download", class = NULL) ), # Show a plot of the generated distribution mainPanel( plotOutput("distPlot") ) ) )) # Define server logic required to draw a histogram server <- shinyServer(function(input, output) { output$distPlot <- renderPlot({ # generate bins based on input$bins from ui.R x <- isolate({faithful[, 2] }) bins <- seq(min(x), max(x), length.out = input$bins + 1) # draw the histogram with the specified number of bins hist(x, breaks = bins, col = 'darkgray', border = 'white') }) output$specDataDownload <- downloadHandler( filename = function() { paste("ProcessedPlateAssay", gsub("-|[[:space:]]|:", "", Sys.time()), ".xlsx", sep = "_") }, content = function(con) { x <- isolate({faithful[, 2] }) bins <- seq(min(x), max(x), length.out = input$bins + 1) output <- createWorkbook() addWorksheet( output, "One") hist( x, breaks = bins, col = 'darkgray', border = 'white') insertPlot( output, sheet = 1, startRow = (1), startCol = 5, width = 6.5, height = 3, fileType = "png", units = "in", dpi = 600) saveWorkbook( wb = output, file = con ) }) }) # Run the application shinyApp(ui = ui, server = server)