shiny: An error has occurred The application failed to start (exited with code 1). please help

Hello,
trying to deploy my first shiny app which lets user select a .txt file, takes first item from Gene.symbol column (separated from others by ///), puts it in new column "Gene.symbol_Unique", reshuffles the columns, displays the table and gives an option to download it.

It is running in r studio, but after trying to publish gives following error:

Thank you very much for help/suggestions and apologies if it looks messy, I am very new to R.

The code of the application is as follows:

library(shiny)
library(tidyverse)  


## Only run examples in interactive R sessions
if (interactive()) {
  
  ui <- fluidPage(
    h1("Upload your GEO2R differential gene expression file 
       and use the download button to retrieve .csv file with multiplicities in Gene.symbol removed."),
    sidebarLayout(
      sidebarPanel(
        fileInput("file1", "Choose your GEO2R .txt File",
                  accept = c(
                    "text/csv",
                    "text/tab-separated-file,text/plain",
                    ".txt")
        ),
        tags$hr(),
        checkboxInput("header", "Header", TRUE)
      ),
      mainPanel(
        downloadLink("downloadData", "Download"),
        tableOutput("contents")
      )
    )
  )
  
  server <- function(input, output) {
   
    
      output$contents <- renderTable({
    
        inFile <- input$file1

        if (is.null(inFile))
          return(NULL)

        data<-read.delim(inFile$datapath, header = input$header)
        
        Gene.symbol_Unique<-data %>% 
          pull(Gene.symbol) %>% 
          str_split("\\///") %>% 
          sapply("[[", 1) %>% 
          str_replace_na(replacement = "")
        
        
        FinalTable<-tibble(data,Gene.symbol_Unique) %>% 
          select(Gene.symbol_Unique,adj.P.Val,logFC, everything())
        
            })
      
      dataFinal<-reactive({
        
        inFile <- input$file1
        
        if (is.null(inFile))
          return(NULL)
        
        data<-read.delim(inFile$datapath, header = input$header)
        
        Gene.symbol_Unique<-data %>% 
          pull(Gene.symbol) %>% 
          str_split("\\///") %>% 
          sapply("[[", 1) %>% 
          str_replace_na(replacement = "")
        
        
        FinalTable<-tibble(data,Gene.symbol_Unique) %>% 
          select(Gene.symbol_Unique,adj.P.Val,logFC, everything()) %>% 
          as.data.frame()
      })
      
      output$downloadData <- downloadHandler(
        filename = function() {
          paste("Gaje_Enrichr", Sys.Date(), ".csv", sep="")
        },
        content = function(file) {
          write.csv(dataFinal(), file)
        }
      )
          

  }
  
  
  shinyApp(ui, server)
}

Session Info:

function (package = NULL) 
{
    z <- list()
    z$R.version <- R.Version()
    z$platform <- z$R.version$platform
    if (nzchar(.Platform$r_arch)) 
        z$platform <- paste(z$platform, .Platform$r_arch, sep = "/")
    z$platform <- paste0(z$platform, " (", 8 * .Machine$sizeof.pointer, 
        "-bit)")
    z$locale <- Sys.getlocale()
    z$running <- osVersion
    z$RNGkind <- RNGkind()
    if (is.null(package)) {
        package <- grep("^package:", search(), value = TRUE)
        keep <- vapply(package, function(x) x == "package:base" || 
            !is.null(attr(as.environment(x), "path")), 
            NA)
        package <- .rmpkg(package[keep])
    }
    pkgDesc <- lapply(package, packageDescription, encoding = NA)
    if (length(package) == 0) 
        stop("no valid packages were specified")
    basePkgs <- sapply(pkgDesc, function(x) !is.null(x$Priority) && 
        x$Priority == "base")
    z$basePkgs <- package[basePkgs]
    if (any(!basePkgs)) {
        z$otherPkgs <- pkgDesc[!basePkgs]
        names(z$otherPkgs) <- package[!basePkgs]
    }
    loadedOnly <- loadedNamespaces()
    loadedOnly <- loadedOnly[!(loadedOnly %in% package)]
    if (length(loadedOnly)) {
        names(loadedOnly) <- loadedOnly
        pkgDesc <- c(pkgDesc, lapply(loadedOnly, packageDescription))
        z$loadedOnly <- pkgDesc[loadedOnly]
    }
    z$matprod <- as.character(options("matprod"))
    es <- extSoftVersion()
    z$BLAS <- as.character(es["BLAS"])
    z$LAPACK <- La_library()
    class(z) <- "sessionInfo"
    z
}
<bytecode: 0x000001b3c8051980>
<environment: namespace:utils>

version:

> version
               _                           
platform       x86_64-w64-mingw32          
arch           x86_64                      
os             mingw32                     
system         x86_64, mingw32             
status                                     
major          3                           
minor          6.3                         
year           2020                        
month          02                          
day            29                          
svn rev        77875                       
language       R                           
version.string R version 3.6.3 (2020-02-29)
nickname       Holding the Windsock        
> 

Do not enclose your code inside this if() statement, when deployed, the code doesn't run interactively on the server so nothing inside gets executed.

Aha!
Fixed it and it works now.
Thank you very much:)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.