logical.rv {rv}R Documentation

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, ...)

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.

Author(s)

Jouni Kerman kerman@stat.columbia.edu http://www.stat.columbia.edu/~kerman

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

  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

[Package rv version 0.949 Index]