I have deployed one shiny application on my server using shiny server. The sample example is shown below:
ui.R
#library(shinyjs)
library(shiny)
#filenames <- list.files(path = "data",pattern="\\.csv$")
#names(filenames) <- gsub(pattern = "\\.csv$", "", filenames)
shinyUI(fluidPage(
titlePanel(
headerPanel(
h3("Testing....",
align="center", style="bold")
)
),
br(),
br(),
#useShinyjs(), ## initialize shinyjs to reset input files.
sidebarLayout(
sidebarPanel(
h5("Upload Data Files",style="bold"),
fileInput("files",
"Choose CSV/txt processed files or raw files",
multiple = "TRUE",
accept=c('text/csv',
'text/comma-separated-values,
text/plain', '.csv','.cel','.TXT','.txt')),
#selectInput('dataset',"Choose platform annotation file", c("Please select a file" ='',filenames)),
fluidRow(
column(5,
radioButtons("radio", label = h5("Data uploaded"),
choices = list("Affymetrix" = 1, "Codelink" = 2,
"Illumina" = 3),selected = NULL)
)
),
fluidRow(
column(10,
h5("Differential Expression Call", style = "bold"),
checkboxInput("checkbox",
label = "Differential Expression", value = FALSE))),
br(),
uiOutput('AnnotationFile')),
mainPanel(
tabsetPanel(id = "MamgedTabs",
tabPanel("Source-data", dataTableOutput("sourced")),
tabPanel("Annotation-data",dataTableOutput("annotation"))
)
)
)
)
)
server.R
#library(gcrma)
#library(hgu133a.db)
#library(hgu133acdf)
#library(hgu133plus2.db)
#library(hgu133plus2cdf)
#library(hgu133a2frmavecs)
#library(hgu133b.db)
#library(hgu133bcdf)
#library(hgu219.db)
#library(hgu219cdf)
#library(hgu95a.db)
#library(hgu95acdf)
#library(org.Hs.eg.db)
#library(hgu133a2.db)
#library(hgu133a2cdf)
#library(hgu95av2.db)
#library(hgu95av2cdf)
#library(hgu133plus2cdf)
#library(affyPLM)
##library(makecdfenv)
#library(parallel)
#library(base)
#library(S4Vectors)
#library(IRanges)
#library(stats4)
#library(BiocInstaller)
#library(Biobase)
#library(BiocGenerics)
#library(BiocParallel)
#library(biomaRt)
#library(Biostrings)
#library(preprocessCore)
#library(affyio)
#library(zlibbioc)
#library(graphics)
#library(grDevices)
#library(methods)
#library(genefilter)
#library(stats)
#library(AnnotationDbi)
#library(utils)
## Defining the size of file to be accepted. Here it can accept any size.
options(shiny.maxRequestSize= -1)
shinyServer(function(input, output,session) {
filenames <- list.files(path = "data", pattern="\\.txt$")
names(filenames) <- gsub(pattern = "\\.txt$", "", filenames)
## Dropdown box for chosing and loading annotation file
output$AnnotationFile = renderUI({
if(!input$checkbox | (input$checkbox == T && input$radio != 2)){
wellPanel(
h5("Upload Annotation File"),
selectInput('dataset', "Choose platform annotation file",
c("Please select a file" = '', filenames), multiple = TRUE))
}
})
})
As you see in the server.R
, I need many packages to be loaded, that takes some time. The below code
output$AnnotationFile = renderUI({
if(!input$checkbox | (input$checkbox == T && input$radio != 2)){
wellPanel(
h5("Upload Annotation File"),
selectInput('dataset', "Choose platform annotation file",
c("Please select a file" = '', filenames), multiple = TRUE))
}
})
is to show are hide something, takes some time to appear, because of the time it take to load the packages, but sometimes it does not display at all.
1) My application works fine locally, but shows this behavior, when deployed on the server. Any reason?
2) How can I display a message on the main panel that the application is getting ready till it load all the packages.
Edit: I can display the message inside shinyServer(), but that is for each session(will load all the packages again and again), however I want to show and load all the packages at the start of the application. In other words, it is to say that how to display progression message outside shinyServer()
renderPrint
might be useful for you and inside that useprint
method to display your message. – Saurabh ChauhanbusyIndicator
from theshinysky
package. For more information follow this link – SBista