check_readline {ratios}R Documentation

check_readline

Description

The function checks if a given character string, e.g. value from readline, matches one element of on a given character vector. Without match it keeps asking for a character string by readline until 'q' for quit or a matching string is provided. This is often used to avoid crashing of functions due to wrong input in the options.

Usage

check_readline(x, myletters)

Arguments

x

character vector to be checked, e.g. value from readline

myletters

character vector of entries which should be allowed, e.g. c("yes", "no")

Details

Usage is e.g. yesno = check_readline(yesno, c("y", "n") Now the function will make sure that the variable x consists either of "y" or of "n".

Value

character vector with one of the values given in myletters

Author(s)

Solveig Pospiech

See Also

Other sub functions: relError_dataset, select.VarsElements

Examples

possibleEntries = c("today", "yesterday")
myEntry = "today"
# or try another entry which is different from "today":
# myEntry = readline("Enter any word (without quotes):   ")
y = check_readline(x = myEntry, myletters = possibleEntries)


[Package ratios version 1.2.0 Index]