部署时未读取R闪亮文件

时间:2018-06-11 11:23:38

标签: r shiny rstudio

更新
问题已解决here




我目前正在创建一个闪亮的应用程序,它可以读取一些.xlsx文件并绘制一些图形。该应用程序在我的本地计算机上运行良好,但在部署时,似乎无法按照目录路径读取文件。该应用程序如下所示:(其中Data是包含.xlsx文件的文件夹)

library(readxl)
library(shiny)

temp = list.files(path = "./Data/" , pattern="*.xlsx")

temp = setNames(temp, make.names(gsub("*.xlsx$", "", temp)))
setwd("./Data")
player_templates = lapply(temp, read_xlsx)


ui <- shinyUI(fluidPage(

  plotOutput('plot'),

  # inputs here

))

server <- function(input, output) {
# server stuff here
}

shinyApp(ui, server)

我尝试过多种变体,包括没有setwd命令,方法是将所有数据放在与this应用相同的文件夹中。不幸的是,结果总是相同的,应用程序按预期发布(所有复选框等),但情节应该在哪里没有。

据我可以从其他答案中看出,通过读取服务器内的数据可以解决问题,但这会减慢应用程序的速度,因此不是一个好的解决方案(根据this)。

修改

这是我尝试没有工作目录的同一问题以供参考。 app.r和所有数据都在这里的同一个文件夹中。

library(readxl)
library(shiny)


temp = list.files(pattern="*.xlsx")


temp = setNames(temp, make.names(gsub("*.xlsx$", "", temp)))
player_templates = lapply(temp, read_xlsx)



ui <- shinyUI(fluidPage(

  plotOutput('plot')

  # inputs here

))

server <- function(input, output) {
  output$plot <- renderPlot({
    # plot here
  })
}

shinyApp(ui, server)

0 个答案:

没有答案
相关问题