简体   繁体   English

ShinyApps:在 Shinyapps.io 上部署时未加载“shinythemes”包

[英]ShinyApps: "shinythemes" package not loading when deployed on Shinyapps.io

I am trying to deploy an R Shiny app online.我正在尝试在线部署 R Shiny 应用程序。 The app runs perfectly when deployed locally.该应用程序在本地部署时运行完美。 It is basically just a dashboard of charts.它基本上只是一个图表仪表板。

However when I deploy it on shinyapps.io, the app only displays the following error:但是,当我在 shinyapps.io 上部署它时,该应用程序仅显示以下错误:

"ERROR: there is no package called 'shinythemes'".

I'm guessing this means that somehow the online version of the app isn't able to load the shinythemes package, but I've search everywhere but I can't seem to find anyone with a similar problem, or a solution.我猜这意味着该应用程序的在线版本无法加载shinythemes包,但我到处搜索,但似乎找不到任何有类似问题或解决方案的人。

Here is the code for the app's ui.R这是应用程序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()
    ))
  )
))

The server.R code has no call to shinythemes so I'm guessing the error lies in ui.R but I can't figure out what needs to be done since I've seen other apps simply call library(shinythemes) and they work. server.R代码没有调用shinythemes所以我猜错误在于ui.R但我无法弄清楚需要做什么,因为我看到其他应用程序只是调用library(shinythemes)并且它们可以工作.

I have re-updated shiny , shinyapps and shinythemes , but to no avail.我重新更新了shinyshinyappsshinythemes ,但无济于事。

Will really appreciate any help on this!非常感谢您对此的任何帮助! Been trying to deploy this app for hours but can't seem to figure it out.一直试图部署这个应用程序几个小时,但似乎无法弄清楚。

This is weird...but I figured out the weirdest solution to this.这很奇怪......但我想出了最奇怪的解决方案。 And somehow it has NOTHING to do with the shinythemes package!不知何故,它与shinythemes包无关! WHAT?!什么?!

So basically, in my server.R code, I included the DT and rsconnect packages.所以基本上,在我的server.R代码中,我包含了DTrsconnect包。 In the ui.R code, I used the hr() and dataTableOutput() functions.在 ui.R 代码中,我使用了hr()dataTableOutput()函数。 Now...the things is that these functions are contained within more than one package that has been loaded:现在......问题是这些函数包含在多个已加载的包中:

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

I simply added the namespace shiny:: before these functions in ui.R as such:我只是在 ui.R 中的这些函数之前添加了命名空间shiny:: ,如下所示:

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

And when I tried deploying them on shinyapps again...WALA!当我再次尝试将它们部署在闪亮的应用程序上时......哇! The app works perfectly!该应用程序完美运行!

I'm just amused by the fact that I practically wasted a full day trying to figure this out, and amused by how the solution had nothing to do with the error message.我很高兴我实际上浪费了一整天的时间试图弄清楚这一点,并且对解决方案与错误消息毫无关系的方式感到好笑。 Hope this saves truckloads of time for anyone who's facing the same problem.希望这可以为面临同样问题的任何人节省大量时间。

Would still like to know why this is the case and why the error message was so misleading...Perhaps something for shiny developers to think about?仍然想知道为什么会出现这种情况以及为什么错误消息如此具有误导性……也许是闪亮的开发人员需要考虑的事情?

Agreed super weird- I had a very similar problem, where I was using DT and had to go through and append things like DT::dataTableOutput() to every section calling the relevant functions.同意超级奇怪 - 我有一个非常相似的问题,我正在使用 DT 并且必须通过并将DT::dataTableOutput()之类的内容附加到调用相关函数的每个部分。

I was able to fix this one with shinythemes::shinytheme() though of course I just uncovered more bugs after that, but hey progress.我可以用shinythemes::shinytheme()修复这个问题,当然在那之后我发现了更多的错误,但是进展顺利。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM