【问题标题】:Error after deploying R shiny app (object not found)部署 R 闪亮应用程序后出错(找不到对象)
【发布时间】:2021-04-29 10:15:35
【问题描述】:

我正在开发我的第一个 shiny 应用程序,在将应用程序发布到 shinyapp.io 服务器时遇到了问题。该应用程序在本地的 R Studio 中运行良好,但是在部署后并在 Web 浏览器中打开时,它会在日志中显示一条错误消息:“Warning: Error in unique: object 'df_app_MT' not found”. 但是 .Rdata 中已经存在“df_app_MT”。我已经浏览了几篇帖子,但错误仍然存​​在。

我已将(ui.R、server.R 和 .Rdata)放在应用程序的文件夹中。还检查了闪亮仪表板,应用程序(状态显示“正在运行”)。这是我当前的 ui.R 代码和日志详细信息以及屏幕截图。请帮助我如何解决此问题。

谢谢你, 图菲克

ui.R

library(shinydashboard)
library(shiny) 
library(dplyr) 
library(ComplexHeatmap) 
library(ggplot2)
library(BiocManager)
options(repos = BiocManager::repositories())


load("datafile.RData")

# Define UI
ui <- dashboardPage(skin = "red",
                    dashboardHeader(title = "Testing") ,
                    dashboardSidebar(
                      sidebarMenu(
                        menuItem("MENU")
                      ),
                      sidebarMenuOutput("menu")
                      
                      
                    ),
                    dashboardBody(
                      tabItems(
                        tabItem("gridfingerprint",
                                fluidRow(
                                  
                                  box(width = NULL,solidHeader = TRUE,
                                      plotOutput("plot2", height = 500)
                                      
                                  ),
                                  fluidRow(
                                    
                                    box(width = NULL,solidHeader = TRUE,
                                        plotOutput("plot_map", height = 500))
                                  ),
                                  fluidRow(
                                    column(width = 4,
                                           box(width = NULL,status = "warning",
                                               downloadButton("gridplot",label = "Download image")
                                           )
                                    ),
                                    column(width = 3, offset = 1,
                                           box(width = NULL, status = "warning",
                                               downloadButton("downloadlist",label = "Download table")    
                                           ))
                                    
                                  )
                                )
                        ),
                        tabItem(tabName = "individualfingerprint", 
                                h5("Fingerprint heatmap displaying patterns of annotated modules across individual study subjects"),
                                fluidRow(
                                  box(width = 12,solidHeader = TRUE, (div(style='width:1400px;overflow: auto;height:800px;',
                                                                          plotOutput("plot4",height = 1200, width = 2550)))
                                  ),
                                  fluidRow(
                                    column(width = 4,
                                           box(width = NULL,status = "warning",
                                               downloadButton("downloadindplot",label = "Download image")
                                           )
                                    ),
                                    column(width = 3, offset = 1,
                                           box(width = NULL, status = "warning",
                                               downloadButton("individualtable",label = "Download table")    
                                           ))
                                    
                                  )
                                )),
                        
                        tabItem("complexplot",
                                fluidRow(
                                  column(width = 12,
                                         box(width = NULL,solidHeader = TRUE, (div(style='width:1400px;overflow: auto;',
                                                                                   plotOutput("plot3",height = 800, width = 4600)))),
                                         fluidRow(
                                           column(width = 4,
                                                  box(width = NULL,status = "warning",
                                                      downloadButton("aggregateplot",label = "Download image")
                                                  )
                                           ),
                                           column(width = 3, offset = 1,
                                                  box(width = NULL, status = "warning",
                                                      downloadButton("downloadaggregate",label = "Download table")    
                                                  ))
                                           
                                         )
                                  )
                                  
                                ))
                      )
                    )
)

server.R

server = function(input, output) {
  output$menu <- renderMenu({
    sidebarMenu(
      menuItem("FINGERPRINT GRIDS", tabName = "gridfingerprint"),
      menuItem("Choose disease", icon = icon("bar-chart-o"),
               # Input directly under menuItem
               selectInput(inputId = "diseaseInput",
                           label = "",
                           choices = unique(df_app_MT$diseases), multiple=F, selectize=TRUE,
                           width = '98%'), tabName = "gridfingerprint"),
      
      
      menuItem("MODULES X STUDIES", tabName = "complexplot"),
      menuItem("Choose aggregate", icon = icon("bar-chart-o"),
               # Input directly under menuItem
               selectInput(inputId = "aggregateInput",
                           label = "",
                           choices = unique(df_app_MT$Aggregate), multiple=F, selectize=TRUE,
                           width = '98%'),tabName = "complexplot"),
      

      menuItem("MODULES X INDIVIDUALS", tabName = "individualfingerprint"),
      menuItem("Choose disease", icon = icon("bar-chart-o"),
               # Input directly under menuItem
               selectInput(inputId = "IllnessInput",
                           label = "",
                           choices = unique(Ind_table_MT$Illness), multiple=F, selectize=TRUE,
                           width = '80%'),
               menuItem("Choose aggregate"),
               selectInput(inputId = "IndaggregateInput",
                           label = "",
                           choices = unique(df_app_MT$Aggregate),selected ="A1", multiple=T, selectize=TRUE,
                           width = '80%'),tabName = "individualfingerprint")
      


    }
  )
}

日志详情

2021-04-29T02:08:20.853366+00:00 shinyapps[4042863]: Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/
2021-04-29T02:08:20.853367+00:00 shinyapps[4042863]: Github page: https://github.com/jokergoo/ComplexHeatmap
2021-04-29T02:08:20.853367+00:00 shinyapps[4042863]: Documentation: http://jokergoo.github.io/ComplexHeatmap-reference
2021-04-29T02:08:20.853368+00:00 shinyapps[4042863]: Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
2021-04-29T02:08:20.853369+00:00 shinyapps[4042863]:   genomic data. Bioinformatics 2016.
2021-04-29T02:08:20.853369+00:00 shinyapps[4042863]: This message can be suppressed by:
2021-04-29T02:08:20.853369+00:00 shinyapps[4042863]:   suppressPackageStartupMessages(library(ComplexHeatmap))
2021-04-29T02:08:20.853370+00:00 shinyapps[4042863]: ========================================
2021-04-29T02:08:20.853370+00:00 shinyapps[4042863]: 
2021-04-29T02:08:21.178976+00:00 shinyapps[4042863]: Bioconductor version 3.12 (BiocManager 1.30.10), ?BiocManager::install for help
2021-04-29T02:08:24.452402+00:00 shinyapps[4042863]: Warning: Error in unique: object 'df_app_MT' not found
2021-04-29T02:08:24.459069+00:00 shinyapps[4042863]:   114: unique
2021-04-29T02:08:24.459069+00:00 shinyapps[4042863]:   108: renderUI [/srv/connect/apps/test/server.R#3]
2021-04-29T02:08:24.459071+00:00 shinyapps[4042863]:    94: renderFunc
2021-04-29T02:08:24.459084+00:00 shinyapps[4042863]:     7: connect$retry
2021-04-29T02:08:24.459070+00:00 shinyapps[4042863]:   107: func
2021-04-29T02:08:24.459071+00:00 shinyapps[4042863]:    93: output$menu
2021-04-29T02:08:24.459071+00:00 shinyapps[4042863]:    13: runApp
2021-04-29T02:08:24.459083+00:00 shinyapps[4042863]:    12: fn
2021-04-29T02:08:24.459085+00:00 shinyapps[4042863]:     5: eval
2021-04-29T02:08:24.459084+00:00 shinyapps[4042863]:     6: eval
2021-04-29T02:42:03.040084+00:00 shinyapps[4042863]: Running on host: ebb9348b6b95
2021-04-29T02:42:03.046218+00:00 shinyapps[4042863]: Server version: 1.8.6.1
2021-04-29T02:42:03.046231+00:00 shinyapps[4042863]: LANG: en_US.UTF-8
2021-04-29T02:42:03.046234+00:00 shinyapps[4042863]: R version: 4.0.3
2021-04-29T02:42:03.046237+00:00 shinyapps[4042863]: shiny version: 1.6.0
2021-04-29T02:42:03.046237+00:00 shinyapps[4042863]: httpuv version: 1.5.5
2021-04-29T02:42:03.046247+00:00 shinyapps[4042863]: rmarkdown version: (none)
2021-04-29T02:42:03.046281+00:00 shinyapps[4042863]: knitr version: (none)
2021-04-29T02:42:03.046298+00:00 shinyapps[4042863]: jsonlite version: 1.7.2
2021-04-29T02:42:03.046308+00:00 shinyapps[4042863]: RJSONIO version: (none)
2021-04-29T02:42:03.046478+00:00 shinyapps[4042863]: Using pandoc: /opt/connect/ext/pandoc/2.11
2021-04-29T02:42:03.046308+00:00 shinyapps[4042863]: htmltools version: 0.5.1
2021-04-29T02:42:03.256647+00:00 shinyapps[4042863]: Starting R with process ID: '24'
2021-04-29T02:42:03.253079+00:00 shinyapps[4042863]: Using jsonlite for JSON processing

【问题讨论】:

  • 你也可以分享server代码吗?
  • @Waldi,非常感谢。我在问题中包含了 server.R 代码(见上文)。
  • 如果您重新启动 R 会话,应用程序是否在本地工作?
  • @Waldi,问题现已解决。我创建了一个 app.R 文件(结合了 ui.R 和 server.R)> 加载了 .Rdata。运行应用程序。该问题现已解决。非常感谢。
  • 好的,完美,你发现了!

标签: r shiny shinydashboard


【解决方案1】:

我看不出从拆分应用程序切换到单文件应用程序会有什么变化,但该应用程序可能第一次无法在同一工作目录中找到 .RData 文件。在本地,如果 df_app_MT 恰好在您的工作环境中,这可能会被忽略。

【讨论】:

  • 当我有 ui.R 和 server.R 时,我尝试了很多方法并遵循了建议。即使 .RData 可用,它也不起作用。所以最后,我制作了 app.R 并使用我能够部署的相同运行 shinyApp (ui =ui, server= server)。
猜你喜欢
  • 1970-01-01
  • 2016-02-24
  • 1970-01-01
  • 1970-01-01
  • 2018-07-09
  • 2018-05-24
  • 2015-04-13
  • 2020-08-07
相关资源
最近更新 更多