I am trying to deploy an app to shinyapps.io that works just fine locally, but will not load online. I get the "Disconnected from the server" message. More befuddling: The logs are not giving me an error message I can identify as pointing to the problem. Here is what the app looks like:
library(shiny)
library(shinythemes)
library(flexdashboard)
library(tidyverse)
library(plotly)
#Modeling
library(randomForest)
library(RCurl)
library(magrittr)
model_rf <- readRDS("model_rf.RData")
denials <- read.csv("denials.csv")
ui<-fluidPage(theme =shinytheme("cosmo"),
fluidRow(
column(8,
h1("Mortgage Denial Calculator"),
column(6,
radioButtons("model_state", label="Please Select State",
choices =list("Florida" = 0, "Arizona" = 2,"Colorado" = 1), selected = 2,inline = TRUE), # STATE SELECT
numericInput("applicant_age",
label="Please input your Age",
value = 27,
min=18,
max=100),
sliderInput("dti_ratio",
label = "Please select your Debt to Income Ratio",
min=0,
max=100,
value= 20)
),#column
column(6,
numericInput("income_amount",
label = "Please input your Household Income",
value= 140000),
numericInput("loan_amount",
label = "Please input your Loan Amount",
value = 400000),
numericInput("down_payment",
label = "Please input your Down Payment",
value=30000)
),
column(12,align = "center", style = "padding-top:3%; padding-bottom:3%;", submitButton("Calculate")),
column(12,align = "center",gaugeOutput("scale"))
),
column(4,
h4("Top reasons applicants in this state were denied a home loan:", style = "padding-top: 50px;"),
div(plotlyOutput("graph"),align = "center")
) # plot
) #full container
)
server<-function(input, output) {
datasetInput <- reactive({
df<-data.frame(
state=factor(input$model_state,levels = c(0,1,2)),
applicant_age=as.integer(input$applicant_age),
income_amount=as.integer(input$income_amount),
loan_amount=as.integer(input$loan_amount),
dti_ratio=as.integer(input$dti_ratio),
down_payment=as.integer(input$down_payment)
)
output<-data.frame(Prediction=predict(model_rf, df), round(predict(model_rf, df, type="prob"),3))
print(output)
})
output$scale <- renderGauge({
gauge(datasetInput()$Denied*100,
min = 0,
max =100,
symbol ='%',
label = 'Probability of Denial',
gaugeSectors(danger = c(80, 100),
warning = c(40,79),
success= c(0,39))
)
})
output$graph <- renderPlotly({
m <- list(l=50, r=20, b=20, t=50, pad=4)
subset(denials, denials$state %in% input$model_state) %>%
dplyr::filter(p!=0.00)%>%
plot_ly(x = ~p,y = ~Denied_Reason,type = 'bar',text = ~p,textposition = 'outside', texttemplate="%{p:$.2f}")%>%
layout(yaxis = list(categoryorder = "total ascending",title="",howgrid = F, showline = F,zeroline = F),
xaxis = list(showticklabels = FALSE, title="", howgrid = F, showline = F,zeroline = F, range = c(0,50)),title = ' ', margin=m)
})
}
shinyApp(ui=ui, server=server)
There is no message in the log beginning "Error: ..." The only messages from the logs that seem to be problematic, though they're familiar with other apps I've deployed successfully:
2022-04-25T15:23:24.303473+00:00 shinyapps[6157631]: ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
2022-04-25T15:23:24.303518+00:00 shinyapps[6157631]: ✖ dplyr::filter() masks stats::filter()
2022-04-25T15:23:24.303563+00:00 shinyapps[6157631]: ✖ dplyr::lag() masks stats::lag()
What is the starting point to investigate a problem like this? How do I tell what is going wrong? Thanks very much in advance for any help!