Question

Let's take a look at one of the demos.

runExample("09_upload")

I am using the supplied file to perform some computations and to display an aggregated performance across all uploaded files. Therefore, I use something like

tryCatch(compute.smth(), error=function(e){})

so that the displayed result is not affected by the bad input. However, I'd like to indicate somehow that uploading the bad file lead to an error, notifying the user about the problem with his input. It'll be something like

tryCatch(compute.smth(), error=badFile())

where badFile() should modify some displayable output. Any ideas? As a last resort, this is probably an option, but I'd like some native Shiny.

Was it helpful?

Solution

You can show alerts like below with the ShinySky package: https://github.com/AnalytixWare/ShinySky

enter image description here

You can install the package using

install.packages("devtools")#if not alrady installed
devtools::install_github("ShinySky","AnalytixWare")

Place a shinyalert(id) in the ui.R for where you want the alert to appear.

In your server.R

  1. Make sure you have a 3 parameters funciton being passed to shinyServer e.g.shinyServer(function(input, output,session) {
  2. use showshinyalert(id,HTMLText,session) to show the alert. Clicking on the alert will dismiss it.
  3. See this gist for example https://gist.github.com/xiaodaigh/7707701

Run this too see an example

shinysky::run.shinysky.example()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top