1
有問題的閃亮應用程序是250行代碼,所以我會嘗試複製下面的相關片段,但它可能是不切實際的,以產生工作重現我遇到的問題的例子。ggplot呈現閃亮的應用程序,但不shinyapps.io,沒有錯誤或警告
當我運行閃亮的應用程序,它在本地運行完美。當我將它部署到shinyapps.io時,我收到成功消息,並且沒有錯誤或警告。但是,當我在瀏覽器中查看shinyapps.io時,沒有任何值框或ggplots可見。
我懷疑問題可能是內存(數據集是500K行)。也許閃亮的應用程序服務器在加載之前耗盡內存?同樣,在日誌中(或者在將應用程序部署到shinyapps.io時,在部署選項卡上)沒有警告,錯誤或相關消息。
在UI中,我有這些行顯示各種圖形和值框:
#Value boxes to show numeric stats
fluidRow(
valueBoxOutput("comp_fare"),
valueBoxOutput("num_comp_fares"),
valueBoxOutput("num_aa_fares")
),
br(),
h2("Impact of continuous features on fares"),
#Select continuous variables
fluidRow(
column(selectInput(inputId = "continuous_variable",
label = "Choose a Variable to Compare: ",
choices = df %>%
select_if(is.numeric) %>% select(-fare) %>%
names,
selected = "distance"
), width = 6),
column(selectInput(inputId = "fit_method",
label = "Choose a Fit Method: ",
choices = c("Linear", "Quadratic"),
selected = "Linear"
), width = 6)
),
br(),
#Plot continuous variables
fluidRow(
plotOutput("cont_plot")
),
br(),
h2("Impact of discrete features on fares"),
#Select factor variables
fluidRow(
column(selectInput(inputId = "factor_variable",
label = "Choose a Variable to Compare: ",
choices = df %>%
select_if(is.factor) %>%
names,
selected = "hub_airport"
), width = 6),
column(selectInput(inputId = "display_layout",
label = "Choose a Display Layout: ",
choices = c("Fill", "Dodge"),
selected = "Dodge"
), width = 6)
),
br(),
#Plot factor variables
fluidRow(
plotOutput("cat_plot")
),
#server code
#ValueBoxes
output$comp_fare <- renderValueBox({
valueBox(competitor_fare_difference(),
"Difference in Competitor Fare",
icon = icon("dollar"),
color = "yellow")
})
output$cont_plot <- renderPlot({
ggplot() +
geom_smooth(data = df2(),
aes_string(input$continuous_variable, "fare", color = "carrier"),
method = "lm",
formula = y ~ poly(x, fit_method())) +
geom_point(data = sample_n(df2(), 1000),
aes_string(input$continuous_variable, "fare", color = "carrier"),
alpha = .3) +
theme_bw() +
scale_y_continuous(labels = dollar) +
labs(title = paste0("Comparison of American Airlines and ", input$competitor),
x = input$continuous_variable,
y = "Round-trip Fare ($US)"
) %>% print
})