Fabi_92
Fabi_92

Reputation: 571

Visualize R program user input questions?

In my R program the user has to type in some inputs. I did this with

readline('Please give the numerical input')

Depending on the input, the program computes further things. My question, is it also possible to visualize the users questions a bit? With readline everything happens in the console. Can I bring it in a nice format to the plot window (for example with a box where user can type in the input and than the program goes on depending on the input)?

Upvotes: 1

Views: 447

Answers (1)

Konrad
Konrad

Reputation: 18585

You may also want to consider two alternatives.

svDialogs

Package svDigalogs would enable you to create an input window realitvly quickly. The code:

require(svDialogs)
## Ask something...
user <- dlgInput("Who are you?", Sys.info()["user"])$res
if (!length(user)) { # The user clicked the 'cancel' button
  cat("OK, you prefer to stay anonymous!\n")
} else {
  cat("Hello", user, "\n")
}

would generate the following window:

Input window

Shiny

Not sure if you considered that but you could quickly put together a Shiny with console and some input field. You could build a dynamic UI element asking user for input, if needed.

Upvotes: 1

Related Questions