2

I am developing an R Shiny application on Windows 7 and would like it to communicate with the user in some ways, primarily outputting some optimization results in the form of a message box.

I tried winDialog() function first but it seems to have only three parameters, thus it's not really customizable. I would have wanted to at least give a proper title for the appearing message box instead of the basic Information title but there doesn't seem to be such an argument. Furthermore, I also dislike winDialog() for being totally platform dependent; if possible, I'd stick to functionalities that won't crash if I give the app to someone using an Apple product...

Then I tried using the tkmessagebox() function from tcltk package but sadly every time the message box appears behind the running app, which first gave me the impression of my app suddenly freezing until I eventually found the message box is hidden behind the app. This is very-very impractical for the user, having to minimize the app window every time, so this didn't solve my issue either.

winDialog(type ="ok", message = paste("Initial profit value is: ", toString(MAX_PROFIT)) )

library(tcltk)
tkmessageBox(title = "Initial profit calculation", message = toString(MAX_PROFIT), icon = "info", type = "ok")

I also came across a thread from last year here on StackOverflow, mentioning the exact same problem with the tkmessageBox function (you can find that thread here: MessageBox in R). Apparently, there doesn't seem to be any straightforward solution for the disappearing R message boxes, or at least I haven't found any information as of now.

lazarea
  • 1,129
  • 14
  • 43
  • 2
    Depending on what you really want to display in the box, perhaps `shinyWidgets`' sweet alert with HTML could be an option. See: https://github.com/dreamRs/shinyWidgets – alex_555 Sep 11 '19 at 11:20
  • 1) Use shiny native https://shiny.rstudio.com/articles/notifications.html 2) I personally like https://github.com/MangoTheCat/shinytoastr – Pork Chop Sep 11 '19 at 12:48

1 Answers1

-1

I use shinyalert package. It works well and does exactly what is required. Here's a neat link: https://deanattali.com/blog/shinyalert-package/

Also, there's a modalDialog box option. This appears like the message box in your browser that asks to allow to send notifications to you. Link: https://shiny.rstudio.com/reference/shiny/latest/modalDialog.html