Is it possible to make a pop-up box appear to the user to input a value in R? I've put together a pair of lines that perform the equivalent function using readline, but is it possible to make the prompt appear somewhere other than the console? Thank you!
Asked
Active
Viewed 1.0k times
6
-
2Right of the bat, tcltk may be of service to you. https://cran.r-project.org/web/packages/tcltk2/index.html – Roman Luštrik Mar 08 '16 at 17:04
-
1FWIW, both **svDialogs** and the (lower level) **tcltk2** package that @RomanLuštrik mentions are written & maintained by the same guy, Philippe Grosjean – Josh O'Brien Mar 08 '16 at 17:25
2 Answers
6
The svDialogs package provides one solution.
Running the following, for example...
library(svDialogs)
## Ask something...
user <- dlgInput("Who are you?", Sys.info()["user"])$res
... gets me the following pop-up input box:
(Whatever value is in the box when you click 'OK' is, as you'd expect, assigned to the symbol user
.)

Josh O'Brien
- 159,210
- 26
- 366
- 455
0
This answer to a similar question shows how to do what you want using the tcltk package (actually it does a little bit more, so could be shortened for what you want). The code is longer than the svDialogs option suggested by Josh O'Brien, but does not require the installation of an additional package (tcltk is one of those that install with R).