This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Shiny write error messages with Validate()

Dear All,

I am trying to use Shiny package from R. I have a user typed input and the code behind takes that input runs it across several databases and returns tables.(See the code attached below) What I need is instead of returning empty tables I should print an error message saying that an input is required. I havent accomplished that (tried validate and need) . Please also note that I am not in liberty to disclose all of the code written. Thank you for your time.

#################################### Server.R ##########################################

shinyServer(function(input, output) {
      datasetInput <- reactive({
    switch(input$dataset,
           "GSE1" = GSE1,
           "none" = null,
           'GSE2'=GSE2)
  })

      data <- reactive({ 
        validate(
          need(input$number != "", "Please enter an input here")
        )
      })

      qualC <- reactive({
        value=as.vector(input$checkGroup)
        value=sprintf('%s_%s.pdf',value,input$dataset)
        print(value)
               })


########################################    UI.R   ########################################

shinyUI(pageWithSidebar(
  # Application title
#
  headerPanel("Representation"),

  # Sidebar with controls to select a dataset and specify the number
  # of observations to view
  sidebarPanel(

   textInput("number", "Enter a gene:", value=""),
   actionButton("Gobutton", "Search"),

   selectInput("dataset", "Choose a dataset:", 
                choices = c('none', 'GSE1',"GSE2")),width=3
  ),

####################################### sessionInfo #############################################

R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252

attached base packages:
 [1] grid      parallel  stats4    stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
 [1] Hmisc_3.17-0              Formula_1.2-1             survival_2.38-3           lattice_0.20-33
 [5] ggplot2_1.0.1             shiny_0.12.2              biomaRt_2.24.1            vsn_3.36.0
 [9] makecdfenv_1.44.0         affyio_1.36.0             BiocInstaller_1.18.4      affy_1.46.1
[13] targetscan.Hs.eg.db_0.6.1 RSQLite_1.0.0             DBI_0.3.1                 AnnotationDbi_1.30.1
[17] GenomeInfoDb_1.4.2        IRanges_2.2.7             S4Vectors_0.6.6           Biobase_2.28.0
[21] BiocGenerics_0.14.0

loaded via a namespace (and not attached):
 [1] reshape2_1.4.1        splines_3.2.2         colorspace_1.2-6      htmltools_0.2.6       XML_3.98-1.3
 [6] foreign_0.8-66        RColorBrewer_1.1-2    plyr_1.8.3            stringr_1.0.0         zlibbioc_1.14.0
[11] munsell_0.4.2         gtable_0.1.2          labeling_0.3          latticeExtra_0.6-26   httpuv_1.3.3
[16] preprocessCore_1.30.0 proto_0.3-10          Rcpp_0.12.1           acepack_1.3-3.3       xtable_1.7-4
[21] scales_0.3.0          limma_3.24.15         jsonlite_0.9.17       mime_0.4              gridExtra_2.0.0
[26] digest_0.6.8          stringi_0.5-5         tools_3.2.2           bitops_1.0-6          magrittr_1.5
[31] RCurl_1.95-4.7        cluster_2.0.3         MASS_7.3-44           R6_2.1.1              rpart_4.1-10
[36] nnet_7.3-11
r shiny

Ummm, how is this related to bioinformatics?

Hello alptaciroglu!

We believe that this post does not fit the main topic of this site.

Not bioinformatics, looks like R and web design

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

1 answer

I just googled, "r shiny data validation" and this tutorial was the first thing.

http://shiny.rstudio.com/articles/validation.html

Is this the one you already tried?

Log in to answer this question.