0

I have built this dashboard that works when displayed locally but will not open when I try to deploy it to shinyapps.io. Based on my troubleshooting, I have specified the wd and made sure all the files are in the directory but haven't had any success. When I attempt to launch the dashboard in shinyapp.io I get the following message: Error: an error has occured. Check your logs or contact the app author for clarification The memory usage does not exceed 120 MB so I don't think that is the root of the problem. Any help would be greatly appreciated. I also would like to know if it is possible to have a selection box with names based on the value selected for location, similar to how it is fairly common to have a dropdown box of states after you've selected your country.

library(shiny)
library(shinydashboard)
library(ggplot2)
library(rsconnect)
library(lubridate)
library(scales)
library(plyr)
library(dplyr)
library(RColorBrewer)
```
```{r}
AdjustedData<- read.csv("Adjusted Data.csv")
Target <- data.frame(yintercept= 40.00, Target= factor(40.00))
AdjustedData$Percentage <- round(AdjustedData$Total.Procedure/AdjustedData$Reconciled.Visits*100, 2)
AdjustedData$Percentage[is.na(AdjustedData$Percentage)] <- 0
opt <- read.csv("optimization.csv")
opt$OptPer <- opt$Optimization*100
opt$Location <- as.character(opt$Location)
opt$Location <- ifelse(opt$Location == "New Jersey" | opt$Location == "Indiana" | opt$Location == "Pennsylvania", "New Jersey/Indiana/Pennsylvania", opt$Location)
opt$Location <- as.factor(opt$Location)



ui <- dashboardPage(
  dashboardHeader(title = "Performance Metrics"), 
  dashboardSidebar(), 
  dashboardBody(
    fluidRow(
            box(title = "Options",
            selectInput(inputId = "Month",
                            label = "Month:", 
                            choices = c("January" = "1", "February" = "2", "March" = "3")),
            selectInput(inputId = "Location",
                        label = "Location:", 
                        choices = c("Illinois", "Wound MD", "Ohio", "New York")), width = 1000, height = 200),

      box(plotOutput("barplot", height = 500, width= 800)),
      box(plotOutput("barplot2", height= 500, width = 800)),
      box(plotOutput("barplot3", height = 500, width = 800))
    )))

server <- function(input, output) {

data <- reactive({
  dataset <- subset(AdjustedData, Location == input$Location & Reconciled.Month == input$Month)
})
data2 <- reactive({
  dataset2 <- subset(opt, Location == input$Location & Month == input$Month)
})
data3<- reactive({
  dataset3 <- subset(data, )
})
 output$barplot <-renderPlot({
    ggplot(data= data(), aes_string(x="Provider",y= "Per.Visit.Bill.Rate", fill = "Per.Visit.Bill.Rate")) +
   geom_bar(stat="identity")+
    labs(caption = "Data sourced from Provider Compensation Analysis and Monthly Summary \nof Billed Physician Encounters Reports. Rates have been adjusted to exclude \nthe deduction per visit for malpractice insurance where applicable.")+
   theme_light()+
   theme(plot.caption = element_text(size= 8, hjust = .5))+
    theme(axis.text.x=element_text(angle= 45, vjust=.5)) +
    ggtitle("Per Visit Bill Rate", input$Location)+
   theme(plot.title = element_text(size = 22, hjust = .5, family = "serif"))+
    theme(plot.subtitle = element_text(size = 18, hjust = .5, family = "serif"))+
   geom_text(aes(label=sprintf("$%.2f",Per.Visit.Bill.Rate)), position=position_dodge(width=0.9),hjust= .5, vjust=0,angle= 0) +
   scale_y_continuous(name = "Per Visit Bill Rate ($)", limits = c(0,100),breaks =seq(0,100,10), labels = dollar)+
   scale_color_continuous()+
   geom_hline(aes(yintercept = yintercept , linetype = Target), data = Target, color = "red", size = 1.0)+
   guides(fill=guide_legend(title = "Per Visit Bill Rate ($)", reverse = TRUE))+
      theme(plot.title = element_text(hjust = 0.5))
  })
 output$barplot2 <-renderPlot({
    ggplot(data= data(), aes_string(x="Provider",y= "Percentage", fill= "Per.Visit.Bill.Rate")) + 
     geom_bar(stat = "identity")+
     geom_text(aes(x=Provider, y= Percentage, label=sprintf("%.1f%%", Percentage)), position=position_dodge(width=0.9),hjust= .5, vjust= 0 ,angle= 0)+
     labs(caption = "Data sourced from Provider Compensation Analysis and \nMonthly Summary of Billed Physician Encounters Reports, March 2018 \nRates have been calculated using the sum of all procedure codes.")+
   scale_y_continuous(name = "Percentage (%)", limits = c(0,100),breaks =seq(0,100,10))+
   scale_color_continuous()+ 
     theme(plot.caption = element_text(size= 8, hjust = .5))+
     theme(axis.text.x=element_text(angle= 0, vjust=.5))+ 
     ggtitle("Procedure Percentages", input$Location)+
     theme(plot.title = element_text(size = 22, hjust = .5, family = "serif"))+
     theme(plot.subtitle = element_text(size = 18, hjust = .5, family = "serif"))+
     guides(fill=guide_legend(title = "Month", reverse =FALSE))
       })
  output$barplot3 <- renderPlot({
    ggplot(data= data2(), aes_string(x = "Provider", y= "OptPer", fill= "OptPer"))+
      geom_bar(stat = "identity") + 
      geom_text(aes(x= Provider, y= OptPer, label=sprintf("%.1f%%", OptPer)), position = position_dodge(width=.6), hjust= .5, vjust=0)+
      theme_light()+
      theme(axis.text.x=element_text(angle= 45, vjust=.5))+
      scale_color_continuous()+
      ggtitle("Optimization Percentages", input$Location)+ 
      labs(caption = "Data sourced from Provider Compensation Analysis Reports, March 2018")+ 
      theme(plot.caption = element_text(size= 8, hjust = .5))+ 
      ylab("Optimization Percentage")+
      theme(plot.title = element_text(size = 22, hjust = .5, family = "serif"))+
      theme(plot.subtitle = element_text(size = 18, hjust = .5, family = "serif"))+ 
      scale_y_continuous(limits= c(0,100), labels = function(x) paste0(x, "%")) + 
      guides(fill=guide_legend(title = "Optimization Percentage (%)", reverse = TRUE))
  })
}
shinyApp(ui, server)

deployApp("DashboardApp.Rmd")

dataset: sample

Provider    Reconciled Month    Per Visit Bill Rate- w/Mal  Per Visit Bill Rate Location
Andrews 1   27.68   30.57   Illinois
Davids  2   25.08   29.08   New York
Stein   3   31.39   31.39   New York
Goodman 2   26.00   30.00   Wyoming
Roberts 3   24.34   25.74   Utah
Buckley 1   29.54   33.54   Ohio
Castro  3   0.00    0.00    Ohio
regents
  • 600
  • 6
  • 15

1 Answers1

0

Is there any particular reason you're hosting the dashboard on an Rmd? If you have to stick to that format, make sure you're not deploying the Rmd file in a directory that contains a Shiny app. You can check this documentation for more details.

  • Yes, @Carlos . If I use an .R file I get the following, `Error in deployApp("DashboardApp.R") : C:\Users\Intern\Documents\Dashboard App\DashboardApp.R must be a directory, an R Markdown document, or an HTML document`. It doesn't matter what format I use, I'm new to R and Shiny and this was just what I could find in my troubleshooting searches – regents Jun 14 '18 at 16:49
  • Try doing these three things: delete ``````{r} from your code, replace the last line `deployApp("DashboardApp.Rmd")` with `shinyApp(ui = ui, server = server)`, and resaving the script as an **app.R** file instead of a DashboardApp.Rmd – Carlos Xavier Bonilla Jun 14 '18 at 19:38
  • No luck. It still opens without a problem locally but I get the same error when I try to deploy it to shinyapps.io. I'm new to this so I only know to use `deployApp("app.R")` so maybe there's a better way? We operate on Mac OS/Windows here so I can't use Shiny Server and I can't secure funding for Shiny Server Pro or R Studio Connect until I can provide results that prove we would be getting something useful out of the money the company spends. – regents Jun 15 '18 at 12:40