ggplot渲染闪亮的应用程序但不在shinyapps.io上,没有错误或警告

时间:2017-07-25 17:22:30

标签: r ggplot2 shiny shinyapps

有问题的闪亮应用程序是250行代码,因此我将尝试复制下面的相关代码段,但是生成一个可以重现我遇到的问题的工作示例可能是不切实际的。

当我运行闪亮的应用程序时,它在本地运行完美。当我将它部署到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
  })

1 个答案:

答案 0 :(得分:0)

问题是shinyapps.io服务器上的可用内存。我把我的数据集采样到更小的东西,它运行得很好。如果其他人遇到这种情况,我看到没有错误或警告,只是加载失败。我希望它可以帮助别人!!