Learn R Programming

rv (version 0.949)

logical.rv: Logical Random vectors

Description

is.logical(x) returns TRUE for each component that contains an logical-valued vector, otherwise FALSE is given.

Usage

## S3 method for class 'rv':
is.logical(x)
  ## S3 method for class 'rv':
as.logical(x, \dots)

Arguments

x
an rv object
...
Further arguments passed on

Details

is.logical(x) returns TRUE if and only if each component of x is logical-valued (i.e. TRUE/FALSE).

as.logical.rv coerces an rv object into logical-valued one. In effect, the function as.logical is applied to all simulations.

References

Kerman, Jouni and Gelman, Andrew. Manipulating and Summarizing Posterior Simulations Using Random Variable Objects. Technical report, Columbia University, New York.

See Also

as.logical.rv, is.logical.rv

Examples

Run this code
x <- rvbern(prob=0.5)   # some 0/1 valued random variable
  is.logical(x)           # FALSE, because by default x is 'double'
  x <- as.logical(x)      # coerce to logical; all zeros become FALSE, ones become TRUE
  is.logical(x)           # TRUE

Run the code above in your browser using DataLab