read.and.check {coda} | R Documentation |
Input is read interactively and checked against conditions specified
by the arguments what
, lower
, upper
and
answer.in
. If the input does not satisfy all the conditions,
an appropriate error message is produced and the user is prompted
to provide input. This process is repeated until a valid input value
is entered.
read.and.check(message = "", what = numeric(), lower, upper, answer.in,
default)
message |
message displayed before prompting for user input. |
what |
the type of |
lower |
lower limit of input, for numeric input only. |
upper |
upper limit of input, for numeric input only. |
answer.in |
the input must correspond to one of the elements of the
vector |
default |
value assumed if user enters a blank line. |
The value of the valid input. When the default
argument is
specified, a blank line is accepted as valid input and in this case
read.and.check
returns the value of default
.
Since the function does not return a value until it receives valid input, it extensively checks the conditions for consistency before prompting the user for input. Inconsistent conditions will cause an error.
Martyn Plummer