Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

packages

shiny

I am trying to deploy an R Shiny app online. 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:

"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.

Here is the code for the app's 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.

I have re-updated shiny,shinyapps and shinythemes, but to no avail.

Will really appreciate any help on this! Been trying to deploy this app for hours but can't seem to figure it out.

like image 569
Jonathan Chow Wen Jun Avatar asked Oct 29 '15 08:10

Jonathan Chow Wen Jun


1 Answers

This is weird...but I figured out the weirdest solution to this. And somehow it has NOTHING to do with the shinythemes package! WHAT?!

So basically, in my server.R code, I included the DT and rsconnect packages. In the ui.R code, I used the hr() and dataTableOutput() functions. 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.
  2. dataTableOutput() is in both shiny and DT.

I simply added the namespace shiny:: before these functions in ui.R as such:

  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?

like image 159
Jonathan Chow Wen Jun Avatar answered Nov 03 '22 23:11

Jonathan Chow Wen Jun