【问题标题】:ShinyApps: "shinythemes" package not loading when deployed on Shinyapps.ioShinyApps:在 Shinyapps.io 上部署时未加载“shinythemes”包
【发布时间】:2016-01-29 06:41:26
【问题描述】:

我正在尝试在线部署 R Shiny 应用程序。该应用程序在本地部署时运行完美。它基本上只是一个图表仪表板。

但是,当我将其部署到 shinyapps.io 时,该应用仅显示以下错误:

"ERROR: there is no package called ‘shinythemes’".

我猜这意味着应用程序的在线版本无法加载 shinythemes 包,但我到处搜索,但似乎找不到任何有类似问题的人,或者一个解决方案。

这是应用程序ui.R的代码

library(shiny)
library(shinythemes)

shinyUI(fluidPage(
  theme = shinytheme("flatly"),
  titlePanel("Bodhi Forest - Website Visitor Analysis"),
  selectInput("user_period","Use Data from the Last",c("7 days" = "7",
                                                       "30 days" = "30",
                                                       "60 days" = "60",
                                                       "90 days" = "90"),
              selected = "30"),
  tabsetPanel(
    tabPanel("Demographics",fluidPage(
      selectInput("Dem_Dim","Dimension",c("Age","Gender")),
      fluidRow(
        column(12,htmlOutput("Dem_Dim"),align="center")
      ),
      br(),
      fluidRow(
        column(6,htmlOutput("Dem_Sessions",inline=TRUE),align="center"),
        column(6,htmlOutput("Dem_SessionLength",inline=TRUE),align="center")
      ),
      br(),
      fluidRow(
        column(6,htmlOutput("Dem_Revenue",inline=TRUE),align="center"),
        column(6,htmlOutput("Dem_RevenuePerTransaction",inline=TRUE),align="center")
      ),
      br(),
      fluidRow(
        column(6,htmlOutput("Dem_Users",inline=TRUE),align="center"),
        column(6,htmlOutput("Dem_NewUsers",inline=TRUE),align="center")
      ),
      br(),
      fluidRow(
        column(6,htmlOutput("Dem_Bounce",inline=TRUE),align="center")
      ),
      hr(),
      fluidRow(
        column(12,dataTableOutput("Dem_Table"))
      ),
      hr()
    )),
    tabPanel("Interests",fluidPage(
      selectInput("Int_Filter","",c(
        "Top 5",
        "Bottom 5"
      )),
      fluidRow(
        column(6,wellPanel(plotOutput("Int_Sessions"))),
        column(6,wellPanel(plotOutput("Int_SessionLength"))),
        column(6,wellPanel(plotOutput("Int_Revenue"))),
        column(6,wellPanel(plotOutput("Int_RevenuePerTransaction"))),
        column(6,wellPanel(plotOutput("Int_Users"))),
        column(6,wellPanel(plotOutput("Int_NewUsers"))),
        column(6,wellPanel(plotOutput("Int_Bounce")))
      ),
      hr(),
      fluidRow(
        column(12,dataTableOutput("Int_Table"))
      ),
      hr()
    ))
  )
))

server.R 代码没有调用shinythemes 所以我猜错误在于ui.R 但我不知道需要做什么,因为我看到其他应用程序只是调用@987654329 @ 他们工作。

我已经重新更新了shiny,shinyappsshinythemes,但是没有用。

非常感谢您对此的任何帮助!尝试部署此应用数小时,但似乎无法弄清楚。

【问题讨论】:

  • 我遇到过几次这个问题,并且总是在 RStudio 项目中,其描述文件中的“导入”部分中不包含有问题的包:stackoverflow.com/a/61325306/1873521
  • 我有同样的问题,但仍然不知道如何解决。

标签: r packages shiny


【解决方案1】:

这很奇怪……但我找到了最奇怪的解决方案。不知何故,它与shinythemes 包无关!什么?!

所以基本上,在我的server.R 代码中,我包含了DTrsconnect 包。在 ui.R 代码中,我使用了 hr()dataTableOutput() 函数。现在...问题是这些函数包含在多个已加载的包中:

  1. hr() 在 shiny 和 rsconnect 中。
  2. dataTableOutput() 在闪亮和 DT 中都有。

我只是在 ui.R 中的这些函数之前添加了命名空间 shiny::

  1. shiny::hr()
  2. shiny::dataTableOutput()

当我再次尝试将它们部署到 shinyapps 上时......哇!该应用程序完美运行!

我很高兴我实际上浪费了一整天的时间来解决这个问题,并且很高兴解决方案与错误消息无关。希望这可以为面临同样问题的任何人节省大量时间。

还想知道为什么会出现这种情况,以及为什么错误消息如此具有误导性...也许是闪亮的开发人员需要考虑的事情?

【讨论】:

  • 我正在尝试类似的方法,但仍然无法正常工作......这真的很令人沮丧。
猜你喜欢
  • 2019-10-27
  • 1970-01-01
  • 2021-03-24
  • 2017-09-05
  • 2019-05-18
  • 2017-12-10
  • 2019-09-30
  • 1970-01-01
  • 2019-04-24
相关资源
最近更新 更多