【问题标题】:Shiny reactive feature not working from one day to another闪亮的反应功能无法从一天到另一天
【发布时间】:2019-08-13 20:13:01
【问题描述】:

我对 stackoverflow 很陌生,对 R shiny 也很陌生,所以感谢您帮助我解决我的问题。

我编写了一个在 Linux 服务器上运行的闪亮应用程序。一切正常,但没有对 ui 或服务器调用进行任何更改,应用程序的两个部分突然停止工作:

  • 点击“更多”标签不再起作用
  • 在“下载中心”中选择一个选项不会显示数据集,下载按钮也不起作用

我已多次重启应用并检查所有软件包是否已正确安装,但没有任何变化。我也没有收到任何错误消息,/var/log/shiny-server 中也没有错误日志。

这是我的代码:

ui <- navbarPage("My App",
tabPanel("Welcome",
         includeHTML("rmd_files/03_welcome.html")
         ),
tabPanel("Download Center",
         fluidRow(
           column(width = 6,
                  h1("Download Center"),
                  p("In this area you can find our Download Center."),
                  p("Select the dataset you are interested in on the left and a description as well as a preview will appear below."),
                  p("You can also download any dataset as a csv to explore it further.")
                  ),
           column(width = 6,
                  # move column down by 20px
                  style = "top: 20px;",
                  # Input: Choose dataset
                  selectInput("dataset", "Choose a dataset:",
                              choices = c("Choose...",
                                          "TestA",
                                          "TestB",
                                          "TestC"
                                          )),
                  # Button: Download data
                  downloadButton("downloadData", "Download CSV")
                  )
         ),
         hr(),
         h4("Dataset description"),
         textOutput("desc_dc"),
         hr(),
         tableOutput("table_dc")
         ),
navbarMenu("More",
           tabPanel("Presentations",
                    p("under construction")
                    ),
           tabPanel("Feature Assessment",
                    p("under construction"),
                    p("Example: ...")
           )
           )
)

##### Define server logic
server <- function(input, output, session) {

# Download Center: Reactive output for selected dataset
dc_dataset <- reactive({
switch(input$dataset,
       "TestA" = testa,
       "TestB" = testb,
       "TestC" = testc
       )
})

# Download Center: Table of selected dataset
output$table_dc <- renderTable({
dc_dataset()
})

# Download Center: Downloadable csv of selected dataset
output$downloadData <- downloadHandler(
filename = function() {
  paste(input$dataset, "_", Sys.Date(), ".csv", sep = "")
},
content = function(file) {
  write.csv(dc_dataset(), file, row.names = FALSE)
}
)

# Download Center: Reactive output for selected dataset  
dc_description <- reactive({
switch(input$dataset,
       "TestA" = testa_desc,
       "TestB" = testb_desc,
       "TestC" = testc_desc
       )
})

# Download Center: Dataset descriptions
output$desc_dc <- renderText({
dc_description()
})

}


# Create Shiny app
shinyApp(ui = ui, server = server)

你能发现一些其他想法有什么帮助吗?会不会和我的 R 版本、Linux 等有关?

>system('shiny-server --version', intern = TRUE)
[1] "Shiny Server v1.5.7.907" "Node.js v8.10.0"

>R --version
R version 3.4.4 (2018-03-15) -- "Someone to Lean On"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

>cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.5 LTS"
NAME="Ubuntu"
VERSION="14.04.5 LTS, Trusty Tahr"

【问题讨论】:

  • 以防万一其他人有同样的问题:显然我在应用程序中包含的一些 Rmd 文件的 html 干扰了其他功能正常工作。我通过将那些 html 包含在 iFrame 中解决了这个问题,从而解决了这个问题。我对它不是很满意,但至少现在整个应用程序又可以运行了。

标签: r shiny


【解决方案1】:

以防万一其他人有同样的问题:显然我在应用程序中包含的一些 Rmd 文件的 html 干扰了其他功能正常工作。我通过将那些 html 包含在 iFrame 中解决了这个问题,从而解决了这个问题。我对此不是很满意,但至少现在整个应用程序又能正常工作了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多