Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use msgbox in R [closed]

How can I display a message box in R ?

I'm looking for something similar to msgbox in VBA, so I can for example alert the user about a problem.

Additionally I would like to allow some user interaction. So for example I could ask the user what day the program should use.

like image 387
dekio Avatar asked Nov 05 '13 17:11

dekio


1 Answers

What do you want to do exactly? Two things come to mind.

You can use the tcl/tk package in R to create a UI. See some examples with code from here: http://www.sciviews.org/_rgui/tcltk/. This package provides quick and easy functions to create message boxes, widgets, and other simple or complicated UIs. I created a point and click pipeline for producing plots in R using this package a couple years ago for users that were unfamiliar with R. I believe that this package is already installed with newer versions of R.

Here is a very simple example you can try:

require(tcltk)
msgBox <- tkmessageBox(title = "Title of message box",
                       message = "Hello, world!", icon = "info", type = "ok")

enter image description here

You can also create message boxes that accept inputs from the user that you can use later, etc. Check out the website I linked for a list of examples to get you started.

Next, we have the newer Shiny interface, which can ask for user input and produce output dynamically over the web, though it is a little more advanced. It provides a user interface through your browser through some simple R code, and the backend is created using R code as well. No javascript or html is required to get a simple set up going, but there is a slight learning curve for coding the Shiny app. You can easily create local Shiny apps by simply installing the shiny package on your local machine, but some set up is required to set up a server to deploy your R app outside of your local system. The RStudio team is offering free accounts on their servers if you want to deploy your R Shiny app over the web. Go to http://www.rstudio.com/shiny/ for some examples, and you can find tutorials at http://rstudio.github.io/shiny/tutorial/.

like image 52
ialm Avatar answered Sep 30 '22 22:09

ialm