check_readline: check_readline

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/Subfunctions.R

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

1
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

1
2
3
4
5
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)

ratios documentation built on May 2, 2019, 3:29 p.m.