title: Error publishing shiny app: app.R did not return a shiny.appobj object
body: <p>I'm creating an app with a simple ML model, the work flow is as follow: </p>
  
  <p>1) Read a file.
  2) Create a model
  3) Plot the prediction and variable importance</p>
  
  <p>Localy, the app is working fine: </p>
  
  <p><a href="https://i.stack.imgur.com/VWRKM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VWRKM.png" alt="enter image description here"></a></p>
  
  <p>But when I try to publish the app, I get following error: </p>
  
  <pre><code>Error in value[[3L]](cond) : app.R did not return a shiny.appobj object.
  Calls: local ... tryCatch -&gt; tryCatchList -&gt; tryCatchOne -&gt; &lt;Anonymous&gt;
  Ejecución interrumpida
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Vo7t6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vo7t6.png" alt="enter image description here"></a></p>
  
  <p>The error is not telling to me, this is the complete code: </p>
  
  <pre><code>library(shiny)
  library(readxl)
  library(tidyverse)
  library(xgboost)
  library(caret)
  library(iml)
  
  
  #### UI
  
  
  ui &lt;- fluidPage(
    sidebarLayout(
      sidebarPanel(
        fileInput("file1", "Choose CSV File",
                  accept = c(
                    "text/csv",
                    "text/comma-separated-values,text/plain",
                    ".csv")
        ),
        tags$hr(),
        checkboxInput("header", "Header", TRUE)
      ),
      mainPanel(
        plotOutput("plot2", click = "plot_brush"),
        plotOutput("plot1", click = "plot_brush")
      )
    )
  )
  
  server &lt;- function(input, output) {
    # create mydata as a reactiveVal so that it can be edited everywhere
    mydata = reactiveVal()
    model &lt;- reactiveValues()
  
  
    # reactive block is changed with an observe that allows mydata to be updated
    # on change of data
    observe({
      req(input$file1, input$header, file.exists(input$file1$datapath))
      data = read.csv(input$file1$datapath, header = input$header)
      mydata(data)
    })
  
  
    output$contents &lt;- renderTable({
      req(mydata())
      #mydata()
    })
  
  
    ### test
    xgb_trcontrol = trainControl(
      method = "cv",
      number = 5,
      allowParallel = TRUE,
      verboseIter = FALSE,
      returnData = FALSE
    )
  
  
    xgbGrid &lt;- expand.grid(nrounds = c(10,14),  # this is n_estimators in the python code above
                           max_depth = c(10, 15, 20, 25),
                           colsample_bytree = seq(0.5, 0.9, length.out = 5),
                           ## The values below are default values in the sklearn-api.
                           eta = 0.1,
                           gamma=0,
                           min_child_weight = 1,
                           subsample = 1
    )
  
  
  
  
    observe({
  
      if ('data.frame' %in% class(mydata()) &amp; !'predicted' %in% names(mydata())){
        set.seed(0)
        xgb_model = train(
          select(mydata(),"LotArea","YrSold"), as.vector(t(mydata()["SalePrice"])),
          trControl = xgb_trcontrol,
          tuneGrid = xgbGrid,
          method = "xgbTree"
        )
  
        predicted = predict(xgb_model, select(mydata(),"LotArea","YrSold"))
        data = mydata()
        data["predicted"] = predicted
        mydata(data)
      }
  
  
      #xgb_model
  
  
  
    })
  
    output$plot1 &lt;- renderPlot({
      data = mydata()
      # this is here to prevent premature triggering of this ggplot.
      # otherwise you'll get the "object not found" error
      if('predicted' %in% names(data)){
        ggplot(mydata(), aes(x=predicted, y=SalePrice)) + geom_point()
      }
    })
  
    output$plot2 &lt;- renderPlot({
      data = mydata()
      # this is here to prevent premature triggering of this ggplot.
      # otherwise you'll get the "object not found" error
      if('predicted' %in% names(data)){
  
        xgb_model = train(
          select(mydata(),"LotArea","YrSold"), as.vector(t(mydata()["SalePrice"])),
          trControl = xgb_trcontrol,
          tuneGrid = xgbGrid,
          method = "xgbTree"
        )
  
        predictor = Predictor$new(xgb_model, data = select(mydata(),"LotArea","YrSold"), y = mydata()["SalePrice"])
        shapley = Shapley$new(predictor, x.interest = select(mydata(),"LotArea","YrSold")[1,])
        shapley$plot()      
      }
    })
  
  
  }
  
  shinyApp(ui, server)
  </code></pre>
  
  <p>And a sample of the input data: </p>
  
  <p><a href="https://drive.google.com/file/d/1R8GA0fW0pOgG8Cpykc8mAThvKOCRCVl0/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1R8GA0fW0pOgG8Cpykc8mAThvKOCRCVl0/view?usp=sharing</a></p>