selectCore {goCluster}R Documentation

A menu function

Description

The function generates a generic textual menu that will return the choice of the user.

Usage

selectCore(message,
convert = function(X) X,
check = function(X) TRUE,
options = NULL,
error = function(X) return("Invalid choice!"),
...
)

Arguments

message The informational message that will be shown together with the menu.
convert A function that converts the user input to a desired format or class type.
check A function that checks the user input for validity.
options The available options as character vector, if any.
error The function that should be executed in case of an error. This should deliver a message that is useful to the user.
... Additional arguments for the convert, check and error functions.

Details

selectCore is a function that provides a generic menu. Currently this is a simple textual menu but it could be extended to a graphical version. The function needs a message that should be displayed to the user, a function to convert the user input to a desired format and another function to check the validity of the user input. Finally a set of options that should be displayed to the user as a numbered list can be specified as a character vector. If convert is not specified, the user input will be used as given (string format) and if check is left unspecified, the check will always return TRUE.

Value

The choice of the user in the format returned by the convert function.

Author(s)

Gunnar Wrobel, http://www.gunnarwrobel.de.

See Also

selectOption, selectDouble, selectNumber.

Examples

## This example needs to be commented since it needs user input
## and would prevent R CMD check from running. Please remove the comment
## in the following line to run the example.

## selectCore("Please choose a number between 0 and 10",convert=function(X) as.integer(X), check=function(X) (X > 0 & X < 10))

[Package goCluster version 1.0.0 Index]