关闭闪亮应用程序时,在服务器上本地保存所有文件

时间:2017-06-13 10:40:35

标签: r shiny save

是否有人知道是否有一种方法可以在应用程序关闭时的闪亮会话中计算的服务器上保存整个环境(或至少是输出对象)。那么,如果用户在下载按钮之前关闭应用程序,那么在服务器上进行某种备份?所以考虑下面的简单示例,我甚至没有下载按钮。如何将绘图和表格输出保存在一个文件中,完全类似于普通R会话中的save.image("file.RData")功能,以及应用程序关闭时保存的附加条件。

ui=fluidPage(
  headerPanel('Iris k-means clustering'),
  sidebarPanel(
    selectInput('xcol', 'X Variable', names(iris)),
    selectInput('ycol', 'Y Variable', names(iris),
                selected=names(iris)[[2]]),
    numericInput('clusters', 'Cluster count', 3,
                 min = 1, max = 9)
  ),
  mainPanel(
    plotOutput('plot1'),
    dataTableOutput('table1')
  )
)



server=function(input, output, session) {

  # Combine the selected variables into a new data frame
  selectedData <- reactive({
    iris[, c(input$xcol, input$ycol)]
  })

  clusters <- reactive({
    kmeans(selectedData(), input$clusters)
  })

  output$plot1 <- renderPlot({
    palette(c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3",
              "#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999"))

    par(mar = c(5.1, 4.1, 0, 1))
    plot(selectedData(),
         col = clusters()$cluster,
         pch = 20, cex = 3)
    points(clusters()$centers, pch = 4, cex = 4, lwd = 4)
  })
  output$table1 <- renderDataTable(iris)
}

shinyApp(ui,server)

有什么想法吗? 非常感谢。

0 个答案:

没有答案