Saturday, 28 May 2016

r - ggplot renders in shiny app but not on shinyapps.io, no errors or warnings

The shiny app in question is 250 lines of code, so I will try to copy the relevant snippets below, but it may be impractical to produce a working example that reproduces the issue I am having.



When I run the shiny app, it runs flawlessly locally. When I deploy it to shinyapps.io, I receive success messages and no errors or warnings. However, when I view the shinyapps.io in the browser none of the valueboxes or ggplots are visible.




I suspect that the issue COULD be memory (the dataset is 500K rows). Maybe the shiny apps server is running out of memory before it loads? Again, no warnings, errors, or relevant messages on the logs (or on the deploy tab when deploying the app to shinyapps.io).



In the ui, I have these rows showing various plots and value boxes:



                  #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
})

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...