boutroslab / CRISPRAnalyzeR

CRISPRAnalyzeR: interactive analysis, annotation and documentation of pooled CRISPR screens
GNU General Public License v2.0
80 stars 31 forks source link

Shiny Dashboard App Deployment Issue #56

Closed umernaeem1 closed 5 years ago

umernaeem1 commented 5 years ago

Hello, I have been trying to publish my shiny dashboard app on shinnyapps.io server. However, even though the app is working locally, I cannot seem to get any success in publishing it online. It gives me this error.

ERROR: An error has occurred. Check your logs or contact the app author for clarification.

I am running a Windows 10 64 bits machine. I tried updating all my R libraries but it also did not help.

My server.r is below

library(shiny)
library(shinydashboard)
library(tidyverse)
library(lubridate)
library(plotly)
library(shinyWidgets)
library(DT)

df <- read.csv("student_data.csv")

df <- df %>%
 mutate(dov = ymd(date_of_visit))

## Value1: Total Schools Covered
tot.school <- df %>% distinct(school) %>% nrow()

## Value2: Total Sudents Present
tot.present <- df %>% filter(student_present == "Present") %>% count()

## Value3: Total Enrolment
tot.enrolment <- df %>% filter(currently_enrolled != "No: Dropped out" & currently_enrolled != "") %>% nrow()

## Value4: Photo Mismatch  
photo.mismatch <- df %>% filter(verified_by_photo == "Mismatched photo") %>% count()

## Value5: Average enrolment by cohort C
avg.enrol <- df %>%
  filter(currently_enrolled != "No: Dropped out" & currently_enrolled != "") %>%
  group_by(school) %>%
  mutate(schl_enrol = n()) %>%
  group_by(cohort) %>%
  summarise(mean = mean(schl_enrol))

avg.enrol.C <- pull(subset(avg.enrol, cohort == "C")[,2])

## Value6: Average enrolment by cohort D
avg.enrol.D <- pull(subset(avg.enrol, cohort == "D")[,2])

############ ------------------------------------------ ############
shinyServer(function(input,output){

## Value1: Total Schools Covered ## 
  output$value1 <- renderValueBox({
    valueBox(
      formatC(tot.school, format="d", big.mark=','),
      paste('Total Schools :',tot.school),
      icon = icon("school",lib='font-awesome'),
      color = "purple") 
  })

## Value2: Total Sudents Present ##
  output$value2 <- renderValueBox({
    valueBox(
      formatC(tot.present$n[1], format="d", big.mark=','),
      paste('Total Present Students :',tot.present$n[1]),
      icon = icon("user-graduate",lib='font-awesome'),
      color = "green") 
  })

## Value3: Total Enrolment ##
  output$value3 <- renderValueBox({
    valueBox(
      formatC(tot.enrolment, format="d", big.mark=','),
      paste('Total Enrolled Students :',tot.enrolment),
      icon = icon("graduation-cap",lib='font-awesome'),
      color = "yellow")
  })

## Value4: Total Photo Mismatches ##  
  output$value4 <- renderValueBox({
    valueBox(
      formatC(photo.mismatch$n[1], format="d", big.mark=','),
      paste('Total Photo Mismatches :',photo.mismatch$n[1]),
      icon = icon("camera-retro",lib='font-awesome'),
      color = "purple")
  })

## Value5: Average enrolment in Cohort C ##
  output$value5 <- renderValueBox({
    valueBox(
      formatC(avg.enrol.C, big.mark=','),
      paste('Average Enrolment in Cohort C :', round(avg.enrol.C,2)),
      icon = icon("graduation-cap",lib='font-awesome'),
      color = "green")
  })

## Value6: Average enrolment in Cohort D ##
  output$value6 <- renderValueBox({
    valueBox(
      formatC(avg.enrol.D, big.mark=','),
      paste('Average Enrolment in Cohort D :', round(avg.enrol.D, 2)),
      icon = icon("address-card",lib='font-awesome'),
      color = "yellow")
  })

  output$histogram <- renderPlotly({
      p <- df %>%
          filter(district == input$dist & (cohort == "C" | cohort == "D")) %>%
          ggplot() + geom_bar(aes(dov)) + facet_wrap(~ cohort, nrow = 1)
      print(p)

  })

  output$mismatch <- renderPlotly({

    p1 <- df %>%
      filter(verified_by_photo != "") %>%
      ggplot() + geom_bar(aes(district, fill = verified_by_photo), position = "dodge")
    print(p1)
  })

  output$absent <- renderPlotly({

    p2 <- df %>%
      filter(student_present != "") %>%
      ggplot() + geom_bar(aes(district, fill = student_present), position = "dodge")
    print(p2)
  })

  output$etable <- DT::renderDataTable({
    df %>%
      group_by(district) %>%
      summarise(
        Minimum  = min(school),
        Maxmimum = max(school),
        Mean     = mean(school)
      )
  })
}
)

My ui.r is below

library(shiny)
library(shinydashboard)
library(tidyverse)
library(lubridate)
library(plotly)
library(shinyWidgets)
library(DT)

shinyUI(
  dashboardPage(
    dashboardHeader(title = "SENSA Dashboard",
                    tags$li(a(img(src = 'logo.jpg',
                                  title = "Company Home", height = "30px"),
                              style = "padding-top:10px; padding-bottom:10px;"),
                            class = "dropdown")),

    dashboardSidebar(
      # sliderInput("bins","Number of Breaks",1,100,50),
      # selectInput("dist",
      #             shiny::HTML("<p><span style='color: black'>Names of District </span></p>"),
      #             choices = c("Select District", levels(df$DISTRICT))),
      pickerInput("dist",
                  shiny::HTML("<p><span style='color: black'>Names of District </span></p>"),
                  choices=levels(df$district),
                  options = list(`actions-box` = TRUE),multiple = T,
                  selected = levels(df$district)),
      sidebarMenu(
      menuItem("Main Dashboard", tabName = "main",
               icon = icon("tachometer")),
      menuItem("Student Information", tabName = "student",
               icon = icon("user-graduate")),
      menuItem("Enumerators Information", tabName = "enum",
               icon = icon("chalkboard-teacher"))
    )),
    dashboardBody(
      tags$head(tags$style(HTML('
                                /* logo */
                                .skin-blue .main-header .logo {
                                background-color: #002147;
                                }

                                /* navbar (rest of the header) */
                                .skin-blue .main-header .navbar {
                                background-color: #002147;
                                }
                                /* body */
                                .content-wrapper, .right-side {
                                background-color: #ffffff;
                                }

                                /* main sidebar */
                                .skin-blue .main-sidebar {
                                background-color: #A6A6A6;
                                }

                                /* other links in the sidebarmenu */
                                .skin-blue .main-sidebar a{
                                background-color: #A6A6A6;
                                color: #000000;
                                font-weight: bold;
                                }

                                /* Hovered side bar*/
                                .skin-blue .main-sidebar .sidebar .sidebar-menu a:hover{
                                background-color: #002147;
                                }

                                /* Active sidebar */
                                .skin-blue .main-sidebar .sidebar .sidebar-menu .active a{
                                background-color: #002147;
                                color: #ffffff;
                                }
                                '))),
      tabItems(
        tabItem(tabName = "main",
                ##########################
                # First row with numbers #
                ##########################
                fluidRow(
                  valueBoxOutput("value1"),
                  valueBoxOutput("value2"),
                  valueBoxOutput("value3")
                ),
                ##########################
                # Second row with graphs #
                ##########################
                fluidRow(
                  column(12,
                         plotlyOutput("histogram"))
                )
                ),
        tabItem(tabName = "student",
                ##########################
                # First row with numbers #
                ##########################
                fluidRow(
                  valueBoxOutput("value4"),
                  valueBoxOutput("value5"),
                  valueBoxOutput("value6")
                ),
                ##########################
                # Second row with graphs #
                ##########################
                fluidRow(
                  column(6,
                         plotlyOutput("mismatch")),
                  column(6,
                         plotlyOutput("absent"))
                )
        ),
        tabItem(tabName = "enum",
                h1("Enumerators Information"),
                fluidRow(
                  column(6,DT::dataTableOutput("etable"))
                )
                   )
      )

  )
  )
)

The logs are below

2019-02-16T10:49:20.011176+00:00 shinyapps[718614]: Using jsonlite for JSON processing
2019-02-16T10:49:20.016162+00:00 shinyapps[718614]: 
2019-02-16T10:49:20.016164+00:00 shinyapps[718614]: Starting R with process ID: '20'
2019-02-16T10:49:20.040355+00:00 shinyapps[718614]: 
2019-02-16T10:49:20.040358+00:00 shinyapps[718614]: Listening on http://127.0.0.1:32854
2019-02-16T10:49:27.148837+00:00 shinyapps[718614]: 
2019-02-16T10:49:27.148842+00:00 shinyapps[718614]: 
2019-02-16T10:49:27.148840+00:00 shinyapps[718614]: Attaching package: ‘shinydashboard’
2019-02-16T10:49:27.149630+00:00 shinyapps[718614]: The following object is masked from ‘package:graphics’:
2019-02-16T10:49:27.149633+00:00 shinyapps[718614]: 
2019-02-16T10:49:27.149636+00:00 shinyapps[718614]: 
2019-02-16T10:49:27.149634+00:00 shinyapps[718614]:     box
2019-02-16T10:49:27.792023+00:00 shinyapps[718614]: ── Attaching packages ─────────────────────────────────────── tidyverse 1.2.1 ──
2019-02-16T10:49:27.797373+00:00 shinyapps[718614]: ✔ ggplot2 3.1.0     ✔ purrr   0.3.0
2019-02-16T10:49:27.903624+00:00 shinyapps[718614]: The following object is masked from ‘package:base’:
2019-02-16T10:49:27.797375+00:00 shinyapps[718614]: ✔ tibble  2.0.1     ✔ dplyr   0.7.8
2019-02-16T10:49:27.797376+00:00 shinyapps[718614]: ✔ tidyr   0.8.2     ✔ stringr 1.4.0
2019-02-16T10:49:27.895297+00:00 shinyapps[718614]: ✖ dplyr::filter() masks stats::filter()
2019-02-16T10:49:27.903628+00:00 shinyapps[718614]: 
2019-02-16T10:49:27.797378+00:00 shinyapps[718614]: ✔ readr   1.3.1     ✔ forcats 0.3.0
2019-02-16T10:49:27.903627+00:00 shinyapps[718614]:     date
2019-02-16T10:49:27.895294+00:00 shinyapps[718614]: ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
2019-02-16T10:49:27.895298+00:00 shinyapps[718614]: ✖ dplyr::lag()    masks stats::lag()
2019-02-16T10:49:27.903625+00:00 shinyapps[718614]: 
2019-02-16T10:49:27.903170+00:00 shinyapps[718614]: 
2019-02-16T10:49:28.001805+00:00 shinyapps[718614]: Attaching package: ‘plotly’
2019-02-16T10:49:27.903172+00:00 shinyapps[718614]: Attaching package: ‘lubridate’
2019-02-16T10:49:28.001801+00:00 shinyapps[718614]: 
2019-02-16T10:49:27.903173+00:00 shinyapps[718614]: 
2019-02-16T10:49:28.001806+00:00 shinyapps[718614]: 
2019-02-16T10:49:28.002240+00:00 shinyapps[718614]: The following object is masked from ‘package:ggplot2’:
2019-02-16T10:49:28.002242+00:00 shinyapps[718614]: 
2019-02-16T10:49:28.002244+00:00 shinyapps[718614]: 
2019-02-16T10:49:28.002243+00:00 shinyapps[718614]:     last_plot
2019-02-16T10:49:28.002794+00:00 shinyapps[718614]: The following object is masked from ‘package:stats’:
2019-02-16T10:49:28.002796+00:00 shinyapps[718614]: 
2019-02-16T10:49:28.002797+00:00 shinyapps[718614]:     filter
2019-02-16T10:49:28.002798+00:00 shinyapps[718614]: 
2019-02-16T10:49:28.003459+00:00 shinyapps[718614]: The following object is masked from ‘package:graphics’:
2019-02-16T10:49:28.003461+00:00 shinyapps[718614]: 
2019-02-16T10:49:28.003462+00:00 shinyapps[718614]:     layout
2019-02-16T10:49:28.003463+00:00 shinyapps[718614]: 
2019-02-16T10:49:28.046480+00:00 shinyapps[718614]: 
2019-02-16T10:49:28.046482+00:00 shinyapps[718614]: Attaching package: ‘DT’
2019-02-16T10:49:28.046483+00:00 shinyapps[718614]: 
2019-02-16T10:49:28.047089+00:00 shinyapps[718614]: The following objects are masked from ‘package:shiny’:
2019-02-16T10:49:28.047091+00:00 shinyapps[718614]: 
2019-02-16T10:49:28.047093+00:00 shinyapps[718614]:     dataTableOutput, renderDataTable
2019-02-16T10:49:28.047094+00:00 shinyapps[718614]: 
2019-02-16T10:49:28.051763+00:00 shinyapps[718614]: Warning: Error in $: object of type 'closure' is not subsettable
2019-02-16T10:49:28.055635+00:00 shinyapps[718614]:   71: levels

Please suggest a solution. Thank you