当使用runApp()从控制台运行以下闪亮的应用程序时,它按预期工作,显示绘图并提供下载包含绘图的Excel文件的功能。在shiny-server上运行相同的应用程序会产生以下错误:
无法打开文件'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)