shiny How to write MCVE (Minimal, Complete, and Verifiable example) Shiny apps Avoid unnecessary details


Example

In practice, shiny Apps are often very complicated and full of features that have been developed over time. More often than not, those additional details are not necessary to reproduce your issue. It is best if you skip such details when writing MCVE's.

WRONG

Why is my plot not showing?

library(shiny)
library(ggplot2)

ui <- fluidPage(
  plotOutput('plot')
)

server <- function(input, output, session){
  df <- data.frame(treatment = rep(letters[1:3], times = 3),
                   context = rep(LETTERS[1:3], each = 3),
                   effect = runif(9,0,1))
  df$treat.con <- paste(df$treatment,df$context, sep = ".")
  df$treat.con <- reorder(df$treat.con, -df$effect, )
  output$plot = renderPlot({
    myPlot <- ggplot(df, aes(x = treat.con, y = effect)) +
       geom_point() +
       facet_wrap(~context, 
                  scales = "free_x",
                  ncol = 1)
  })
}

shinyApp(ui, server)

RIGHT

Why is my Plot not showing?

library(shiny)
library(ggplot2)

ui <- fluidPage(
  plotOutput('plot')
)

server <- function(input, output, session){
  output$plot = renderPlot({
    myPlot <- ggplot(mtcars, aes(mpg, wt)) + geom_point() 
  })
}

shinyApp(ui, server)