issue deploying app

54 views
Skip to first unread message

Emily Kotnik

unread,
Jun 15, 2018, 8:52:15 AM6/15/18
to shinyapps.io Users
This is my first attempt at creating a dashboard so I'm sure this is simple fix, but I am having issues deploying my app to shinyapps,io. If I save the app as app.Rmd it will deploy to the server but when I try to launch the app from shinyapps,io I get an error. If it is saved as app.R I get an error that eon't allow me to deploy it to shinyapps.io. We work on windows/mac os here and I am not in a position to secure funding for shiny server, shiny server pro, or rstudio connect at this point. This code does work locally.
below is my code:

library(shiny)
library(shinydashboard)
library(ggplot2)
library(rsconnect)
library(lubridate)
library(scales)
library(plyr)
library(dplyr)
library(RColorBrewer)

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)
mu <- mean(opt$OptPer)
res <- as.vector(opt$OptPer-mu)
opt <- cbind(opt, res)


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)),
      box(plotOutput("scatterplot", 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)
})

 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))
  })
  output$scatterplot <- renderPlot({
    ggplot(data = data2(), aes_string(x= "Provider", y="res"))+
      geom_line(data= data2(), aes(x = "Provider", ymax = "res", ymin = "0"))+
      geom_hline(yintercept = 0)+
      theme_light()+
      scale_color_manual("red", "black")+
      ggtitle("Variation from Average Optimization")+
     theme(plot.title = element_text(size = 22, hjust = .5, family = "serif"))+
     theme(plot.subtitle = element_text(size = 18, hjust = .5, family = "serif"))
  })
}
shinyApp(ui = ui, server = server)


Emily Kotnik

unread,
Jun 15, 2018, 9:08:08 AM6/15/18
to shinyapps.io Users
Sample data:

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

Joshua Spiewak

unread,
Jun 18, 2018, 11:06:58 AM6/18/18
to shinyapps.io Users
It doesn't look like an RMarkdown document, so let's put aside digging into the error you get when you deploy it as such.

What error are you getting when attempting to deploy as an app.R?


On Friday, June 15, 2018 at 8:52:15 AM UTC-4, Emily Kotnik wrote:
Reply all
Reply to author
Forward
0 new messages