1

我有一个目录中的文件列表,我想通过 R shinny 在图形中显示每个文件的信息。我使用 list.files 函数,然后使用变量 i 在文件中进行循环。使用闪亮,我会使用 i 作为交互式变量。所以我尝试了这样的事情:

Server.R
shinyServer(function(input, output) {

data=reactive({
data=read.table(list.files(directory)[input$i])
data
})

output$Plot <- renderPlot({
    plot(data()["variable1"],data()["variable2"]])
})

UI.R

shinyUI(pageWithSidebar(
 sidebarPanel(
numericInput("i", "Indice:",
                min = 1, max = length(list.files(directory)), value = 1)

              )
 mainPanel(
   plotOutput("Plot")
    )
))

它适用于 i=1,但是当我选择另一个 i 值时它停止工作(屏幕变为灰色)。我相信错误出现在我使用数据框的形式中,有人可以帮助我吗?

谢谢

4

0 回答 0