Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

read.and.check

Read data interactively and check that it satisfies conditions


Description

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.

Usage

read.and.check(message = "", what = numeric(), lower, upper, answer.in,
default)

Arguments

message

message displayed before prompting for user input.

what

the type of what gives the type of data to be read.

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 answer.in, if supplied.

default

value assumed if user enters a blank line.

Value

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.

Note

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.

Author(s)

Martyn Plummer


coda

Output Analysis and Diagnostics for MCMC

v0.19-4
GPL (>= 2)
Authors
Martyn Plummer [aut, cre, trl], Nicky Best [aut], Kate Cowles [aut], Karen Vines [aut], Deepayan Sarkar [aut], Douglas Bates [aut], Russell Almond [aut], Arni Magnusson [aut]
Initial release
2020-09-30

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.