0

in the below application, is there a way to get rid of red color error message ? like whenever there is a error message, we may require nothing to be printed there (Just blank). Is it possible to achieve.........................

---
title: "Untitled"
runtime: shiny
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(dplyr)
library(DT)
library(dplyr)
library(shiny)
```

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

```{r}
selectInput("Tic", "", choices = c("", "ALL", as.character(iris$Species)), selected = NULL)
actionButton("Submit", "Submit")
textOutput("Total")
tableOutput("SUMMARY_GENERAL_table")


data2 <- reactiveVal(iris[1:2, ])

observeEvent(input$Submit, {
  if (input$Tic == "") {
    table_display <- iris[1:2, ]
  } else if (input$Tic == "ALL") {
    table_display <- iris
  }  else {
    table_display <- iris %>% filter(Species %in% input$Tic)
  }

  data2(table_display)
})


output$SUMMARY_GENERAL_table <- renderTable({
  data2()
})

output$Total <- renderText(
  paste0("Sum ", formatC(as.numeric(sum(data2()[(data2()$Species == "virginica"), ]$Species))))
)
```


imran p
  • 332
  • 2
  • 12
  • Have you tried using `try` or `tryCatch`? – r2evans Feb 05 '20 at 19:32
  • 2
    You can set `options(show.error.messages = FALSE)`, but that may mean your app stops with no indication why. A better approach might be looking into recovering/handling the error, with, e.g, [tryCatch](https://stackoverflow.com/q/12193779/903061) – Gregor Thomas Feb 05 '20 at 19:33

1 Answers1

0

As smurfit89 mentioned above, it's generally not a good idea to do it. However, there are some situations where it would be nice, such as if you already know it will give one.

If you do insist on doing it, though, an easy way to do it is suppressWarnings(expr)