Hello,
I've been learning Shiny, so forgive me for being a nubile here. I have gathered and munged data from the department of education (IPEDS) and the Census Bureau and am making from those data. I have a strange issue on the scatterplot on the last tab of my app. I can get it to launch and work great locally, but when I deploy it on the web, my pickerInput will not select New Mexico (NM) or Puerto Rico(PR). It gives an error message ("An error has occurred. Check your logs or contact the app author for clarification). Again, I am able to make it launch locally. Once I publish it, it works on every state except NM an PR. Could this mean that I need to upgrade my membership for more data, or is there something else going on? I checked the logs too and pasted them below the code. I wasn't sure how to interpret that.
Here is the link to the app:
https://marksresearch.shinyapps.io/IPEDS_Dash/
Here is my code. I am not sure how to share the .csv files:
library(plotly)
library(dplyr)
library(ggpubr)
library(gridExtra)
library(scales)
library(shiny)
library(shinyWidgets)
library(shinydashboard)
library(leaflet)
GradRate<- read.csv("GradRate.csv")
BachRate<- read.csv("BachRate.csv")
RetentionRate<- read.csv("RetentionRate.csv")
EnrollmentDB<- read.csv("EnrollmentDB.csv")
Demograph<- read.csv("Demograph.csv")
Community<- read.csv("Community.csv")
ui <- dashboardPage(skin = "purple",
dashboardHeader(title = "IPEDS Dashboard"),
dashboardSidebar(
sidebarMenu(
menuItem("Historic Enrollment", tabName = "histenroll", icon = icon("user")),
menuItem("Demographics", tabName = "demos", icon = icon("user")),
menuItem("Com. College Grad Rates", tabName = "ccgraduation", icon = icon("user")),
menuItem("Bach. Degree Grad Rates", tabName = "bagraduation", icon = icon("user")),
menuItem("Retention Rates", tabName = "retentionrate", icon = icon("user")),
menuItem("Correlations", tabName = "correlations", icon = icon("user"))
)),
dashboardBody(
tabItems(
tabItem(tabName = "histenroll",
fluidRow(
selectInput("stateInput4", "Select One or More States:",
choices = sort(unique(EnrollmentDB$State)),
selected = "WY", multiple = TRUE),
uiOutput("instInput4")),
fluidRow(
box(plotlyOutput("plot4", height = 500), width = 1000))),
tabItem(tabName = "demos",
fluidRow(
selectInput("stateInput5", "Select One or More States:",
choices = sort(unique(Demograph$State)),
selected = "WY", multiple = TRUE),
uiOutput("instInput5")),
fluidRow(
box(plotlyOutput("plot5", height = 500), width = 1000))),
tabItem(tabName = "ccgraduation",
fluidRow(
selectInput("stateInput", "Select One or More States:",
choices = sort(unique(GradRate$State)),
selected = "WY", multiple = TRUE),
uiOutput("instInput")),
fluidRow(
box(plotlyOutput("plot", height = 500), width = 1000))),
tabItem(tabName = "bagraduation",
fluidRow(
selectInput("stateInput2", "Select One or More States:",
choices = sort(unique(GradRate$State)),
selected = "WY", multiple = TRUE),
uiOutput("instInput2")),
fluidRow(
box(plotlyOutput("plot2", height = 500), width = 1000))),
tabItem(tabName = "retentionrate",
fluidRow(
selectInput("stateInput3", "Select One or More States:",
choices = sort(unique(RetentionRate$State)),
selected = "WY", multiple = TRUE),
uiOutput("instInput3")),
fluidRow(
box(plotlyOutput("plot3", height = 500), width = 1000))),
tabItem(tabName = 'correlations',
fluidRow(
varSelectInput(
inputId = "xvar",
label = "Select an X variable",
data = Community,
selected = "Percent_Women")),
fluidRow(
varSelectInput(
inputId = "yvar",
label = "Select a Y variable",
data = Community,
selected = "Percent_FT")),
fluidRow(
pickerInput("stateInput6", "Select a State:",
choices = sort(unique(Community$State)),
options = list('actions-box' = TRUE), multiple = TRUE,
selected = "WY")),
fluidRow(
box(plotlyOutput("plot6", height = 500), width = 1000)))
))
)
server <- function(input, output, session) {
Community College Degrees
df0 <- eventReactive(input$stateInput,{
GradRate %>% filter(State %in% input$stateInput)
})
output$instInput <- renderUI({
selectInput("instInput", "Next Select One or More Colleges:", sort(unique(df0()$Institution)), selected = "Casper College", multiple = TRUE)
})
df1 <- eventReactive(input$instInput,{
df0() %>% filter(Institution %in% input$instInput)
})
#####Bachelor Degrees
df2 <- eventReactive(input$stateInput2,{
BachRate %>% filter(State %in% input$stateInput2)
})
output$instInput2 <- renderUI({
selectInput("instInput2", "Next Select One or More Colleges:", sort(unique(df2()$Institution)), selected = "University of Wyoming", multiple = TRUE)
})
df3 <- eventReactive(input$instInput2,{
df2() %>% filter(Institution %in% input$instInput2)
})
#####Retention
df4 <- eventReactive(input$stateInput3,{
RetentionRate %>% filter(State %in% input$stateInput3)
})
output$instInput3 <- renderUI({
selectInput("instInput3", "Next Select One or More Colleges:", sort(unique(df4()$Institution)),
selected = "Casper College", multiple = TRUE)
})
df5 <- eventReactive(input$instInput3,{
df4() %>% filter(Institution %in% input$instInput3)
})
####Historical Enrollment
df6 <- eventReactive(input$stateInput4,{
EnrollmentDB %>% filter(State %in% input$stateInput4)
})
output$instInput4 <- renderUI({
selectInput("instInput4", "Next Select One or More Colleges:", sort(unique(df6()$Institution)),
selected = "Casper College", multiple = TRUE)
})
df7 <- eventReactive(input$instInput4,{
df6() %>% filter(Institution %in% input$instInput4)
})
#####Demographics
df8 <- eventReactive(input$stateInput5,{
Demograph %>% filter(State %in% input$stateInput5)
})
output$instInput5 <- renderUI({
selectInput("instInput5", "Next Select One or More Colleges:", sort(unique(df8()$Institution)),
selected = "Casper College", multiple = TRUE)
})
df9 <- eventReactive(input$instInput5,{
df8() %>% filter(Institution %in% input$instInput5)
})
####
ab<- reactive({
Community %>%
filter(State %in% input$stateInput6)
})
#################################################################################################
######Make demographic Plot
output$plot5 <- renderPlotly({
demo<- ggplot(df9(), aes(x = Demographic, y = Percent, group = Institution, fill = Institution,
text=paste("Institution:",Institution, "<br />State:",State, "<br />Demographic:",Demographic,
"<br />Percent:",Percent%>%paste("%"))))+
geom_bar(stat = "summary", fun = "mean")+
ggtitle("Demographics")+
xlab("")+
ylab("Percent")+
facet_grid(vars(Institution), shrink = TRUE)+
geom_text(aes(label = paste0(Percent,"%")), position=position_nudge(y = 4), size = 3, stat = "summary")+
scale_y_continuous(labels = function(x) paste0(x, "%"))+
scale_fill_brewer(palette = "Dark2")+
coord_flip()+
theme(axis.text.x = element_text(angle = 45))
ggplotly(demo, tooltip = 'text')
})
#####Make Enrollment Plot
output$plot4 <- renderPlotly({
enroll<-
ggplot(df7(), aes(x = factor(Year), y = Enrollment, group = Institution, color = Institution,
text=paste("Institution:",Institution, "<br />State:",State, "<br />Year:",Year,"<br />Enrollment Total:", Enrollment)))+
geom_line()+
geom_point()+
ggtitle("Fall Enrollment")+
xlab("")+
ylab("Enrollment")+
geom_text(aes(label = Enrollment), position=position_nudge(y = 20), size = 3, stat = "summary")+
scale_color_brewer(palette = "Dark2")
ggplotly(enroll, tooltip = 'text')
})
####Make CC Plot
output$plot <- renderPlotly({
grad<- ggplot(df1(), aes(x = RateLevel, y = Rate, group = Institution, fill = Institution,
text=paste("Institution:",Institution, "<br />State:",State, "<br />Rate Level:",RateLevel,"<br />Graduation Rate:",Rate%>%paste("%"))))+
geom_bar(stat = "summary", fun = "mean")+
ggtitle("Graduation Rates")+
xlab("")+
ylab("Graduation Rate")+
facet_grid(vars(Institution))+
geom_text(aes(label = paste0(Rate,"%")), position=position_nudge(y = 1), size = 4, stat = "summary")+
scale_y_continuous(labels = function(x) paste0(x, "%"))+
scale_fill_brewer(palette = "Dark2")
ggplotly(grad, tooltip = 'text')
})
###Make Bachelor's Plot
output$plot2 <- renderPlotly( {
bagrad<- ggplot(df3(), aes(x = RateLevel, y = Rate, group = Institution, fill = Institution,
text=paste("Institution:",Institution, "
State:",State, "
Rate Level:",RateLevel,"
Graduation Rate:",Rate%>%paste("%"))))+
geom_bar(stat = "summary", fun = "mean")+
ggtitle("Bachelor Degree Graduation Rates (2018 IPEDS)")+
ylab("Graduation Rate")+
xlab("")+
facet_grid(vars(Institution))+
geom_text(aes(label = paste0(Rate,"%")), position=position_nudge(y = 1), size = 3, stat = "summary")+
scale_y_continuous(labels = function(x) paste0(x, "%"))+
scale_fill_brewer(palette = "Dark2")
ggplotly(bagrad, tooltip = 'text')
})
###Make Retention Plot
output$plot3 <- renderPlotly({
Ret<- ggplot(df5(), aes(x = RateLevel, y = Rate, group = Institution, fill = Institution,
text=paste("Institution:",Institution, "<br />State:",State, "<br />Rate Level:",RateLevel,"<br />Graduation Rate:",Rate%>%paste("%"))))+
geom_bar(stat = "summary", fun = "mean")+
ggtitle("Retention Rates")+
ylab("Retention Rate")+
xlab("")+
facet_grid(vars(Institution))+
geom_text(aes(label = paste0(Rate,"%")), position=position_nudge(y = 1), size = 3, stat = "summary")+
scale_y_continuous(labels = function(x) paste0(x, "%"))+
scale_fill_brewer(palette = "Dark2")
ggplotly(Ret, tooltip = 'text')
})
###Make Correlation Plot
output$plot6 <- renderPlotly({
com<- ggplot(ab(), aes_string(x = input$xvar, y =input$yvar))+
geom_point(aes(color = Community_Type, label1 = State, label2= County, label3 = Institution))+
geom_smooth(method = "lm")+
theme(axis.text.x = element_text(angle = 45))+
scale_color_discrete(name = " ")
ggplotly(com)
})
}
shinyApp(ui=ui, server=server)
Logs:
2021-08-04T05:36:18.283905+00:00 shinyapps[4454818]:
2021-08-04T05:36:18.284230+00:00 shinyapps[4454818]: The following objects are masked from ‘package:base’:
2021-08-04T05:36:18.284231+00:00 shinyapps[4454818]:
2021-08-04T05:36:18.284231+00:00 shinyapps[4454818]: intersect, setdiff, setequal, union
2021-08-04T05:36:18.284232+00:00 shinyapps[4454818]:
2021-08-04T05:36:18.516707+00:00 shinyapps[4454818]:
2021-08-04T05:36:18.516709+00:00 shinyapps[4454818]: Attaching package: ‘gridExtra’
2021-08-04T05:36:18.516710+00:00 shinyapps[4454818]:
2021-08-04T05:36:18.516995+00:00 shinyapps[4454818]: The following object is masked from ‘package:dplyr’:
2021-08-04T05:36:18.516996+00:00 shinyapps[4454818]:
2021-08-04T05:36:18.516997+00:00 shinyapps[4454818]: combine
2021-08-04T05:36:18.516997+00:00 shinyapps[4454818]:
2021-08-04T05:36:18.578767+00:00 shinyapps[4454818]:
2021-08-04T05:36:18.578769+00:00 shinyapps[4454818]: Attaching package: ‘shinydashboard’
2021-08-04T05:36:18.578770+00:00 shinyapps[4454818]:
2021-08-04T05:36:18.579071+00:00 shinyapps[4454818]: The following object is masked from ‘package:graphics’:
2021-08-04T05:36:18.579072+00:00 shinyapps[4454818]: box
2021-08-04T05:36:18.579071+00:00 shinyapps[4454818]:
2021-08-04T05:36:18.579072+00:00 shinyapps[4454818]:
2021-08-04T05:36:18.794929+00:00 shinyapps[4454818]:
2021-08-04T05:36:18.794930+00:00 shinyapps[4454818]: Listening on http://127.0.0.1:33209
2021-08-04T05:36:21.849023+00:00 shinyapps[4454818]: Please use group_by()
instead.
2021-08-04T05:36:21.758625+00:00 shinyapps[4454818]: No summary function supplied, defaulting to mean_se()
2021-08-04T05:36:21.849020+00:00 shinyapps[4454818]: Warning: group_by_()
was deprecated in dplyr 0.7.0.
2021-08-04T05:36:21.849025+00:00 shinyapps[4454818]: Call lifecycle::last_warnings()
to see where this warning was generated.
2021-08-04T05:36:21.849023+00:00 shinyapps[4454818]: See vignette('programming') for more help
2021-08-04T05:36:21.849024+00:00 shinyapps[4454818]: This warning is displayed once every 8 hours.
2021-08-04T05:37:41.972179+00:00 shinyapps[4454818]: Warning: Ignoring unknown aesthetics: label1, label2, label3
2021-08-04T05:37:41.984069+00:00 shinyapps[4454818]: geom_smooth()
using formula 'y ~ x'
2021-08-04T05:37:45.070976+00:00 shinyapps[4454818]: Warning: Ignoring unknown aesthetics: label1, label2, label3
2021-08-04T05:37:45.088615+00:00 shinyapps[4454818]: geom_smooth()
using formula 'y ~ x'
2021-08-04T05:37:45.089579+00:00 shinyapps[4454818]: Warning: Removed 3 rows containing non-finite values (stat_smooth).
2021-08-04T05:37:45.191171+00:00 shinyapps[4454818]: Warning: Error in gsub: input string 578 is invalid in this locale
2021-08-04T05:37:45.196715+00:00 shinyapps[4454818]: 117: FUN
2021-08-04T05:37:45.196714+00:00 shinyapps[4454818]: 119: FUN
2021-08-04T05:37:45.196714+00:00 shinyapps[4454818]: 120: gsub
2021-08-04T05:37:45.196727+00:00 shinyapps[4454818]: 108: getFromNamespace("prepareWidget", "plotly")
2021-08-04T05:37:45.196715+00:00 shinyapps[4454818]: 118: lapply
2021-08-04T05:37:45.196717+00:00 shinyapps[4454818]: 112: plotly_build.plotly
2021-08-04T05:37:45.196716+00:00 shinyapps[4454818]: 116: lapply
2021-08-04T05:37:45.196717+00:00 shinyapps[4454818]: 113: translate_linebreaks
2021-08-04T05:37:45.196716+00:00 shinyapps[4454818]: 115: FUN
2021-08-04T05:37:45.196732+00:00 shinyapps[4454818]: 6: eval
2021-08-04T05:37:45.196716+00:00 shinyapps[4454818]: 114: lapply
2021-08-04T05:37:45.196731+00:00 shinyapps[4454818]: 12: fn
2021-08-04T05:37:45.196729+00:00 shinyapps[4454818]: 107: func
2021-08-04T05:37:45.196732+00:00 shinyapps[4454818]: 7: connect$retry
2021-08-04T05:37:45.196729+00:00 shinyapps[4454818]: 94: renderFunc
2021-08-04T05:37:45.196729+00:00 shinyapps[4454818]: 93: output$plot6
2021-08-04T05:37:45.196730+00:00 shinyapps[4454818]: 13: runApp
2021-08-04T05:37:45.196732+00:00 shinyapps[4454818]: 5: eval