getChoice {PBSmodelling} | R Documentation |
Prompts the user to choose one string item from a list of
choices displayed in a GUI. The simplest case getChoice()
yields TRUE
or FALSE
.
getChoice(choice=c("Yes","No"), question="Make a choice: ", winname="getChoice", horizontal=TRUE, radio=FALSE, qcolor="blue", gui=FALSE, quiet=FALSE)
choice |
vector of strings from which to choose. |
question |
question or prompting statement. |
winname |
window name for the getChoice GUI. |
horizontal |
logical: if TRUE , display the choices horizontally, else vertically. |
radio |
logical: if TRUE , display the choices as radio buttons, else as buttons. |
qcolor |
colour for question . |
gui |
logical: if TRUE , getChoice is functional when called from a GUI,
else it is functional from command line programs. |
quiet |
logical: if TRUE , don't print the choice on the command line. |
The user's choice is stored in .PBSmod$options$getChoice
(or whatever winname
is supplied).
getChoice
generates an onClose
function that returns focus
to the calling window (if applicable) and prints out the choice.
If called from a GUI (gui=TRUE
), no value is returned directly. Rather,
the choice is written to the PBS options workspace, accessible through
getPBSoptions("getChoice")
(or whatever winname
was supplied).
If called from a command line program (gui=FASLE
), the choice is returned
directly as a string scalar (e.g., answer <- getChoice(gui=F)
).
Microsoft Windows users may experience difficulties switching focus between the R console and GUI windows. The latter frequently disappear from the screen and need to be reselected (either clicking on the task bar or pressing <Alt><Tab>. This issue can be resolved by switching from MDI to SDI mode. From the R console menu bar, select <Edit> and <GUI preferences>, then change the value of “single or multiple windows” to SDI.
chooseWinVal
, getWinVal
, setWinVal
## Not run: #-- Example 1 getChoice(c("Fame","Fortune","Health","Beauty","Lunch"), "What do you want?",qcolor="red",gui=F) #-- Example 2 getChoice(c("Homer Simpson","Wilberforce Humphries","Miss Marple"), "Who`s your idol?",horiz=F,radio=T,gui=F) ## End(Not run)