rvmatch: Generate a Random Vector from a Bernoulli Sampling Model

Description Usage Arguments Details Value Author(s) References Examples

View source: R/rvmatch.R

Description

rvmatch returns a (random) vector of the positions of (first) matches of its first argument in its second.

%*in*% is a binary operator (analogous in its operation to %in%) which returns a logical (random) vector indicating if there is a match or not for its left operand.

Usage

1
2
  rvmatch(x, table, nomatch = NA_integer_, incomparables = NULL)
  x %*in*% y

Arguments

x

random vector, regular atomic vector, or NULL: the values to be matched.

table, y

random vector, regular atomic vector, or NULL: the values to be matched against.

nomatch

the value to be returned in the case when no match is found. Note that the value is coerced to integer.

incomparables

a vector of values that cannot be matched. Any value in x matching a value in this vector is assigned the nomatch value. For historical reasons, FALSE is equivalent to NULL

Details

...

Value

A random vector (an rv object) of the same length as x.

rvmatch returns an integer-valued vector.

%*in*% returns a logical-valued vector.

Both functions are compatible with regular atomic vectors.

Author(s)

Jouni Kerman jouni@kerman.com

References

Kerman, J. and Gelman, A. (2007). Manipulating and Summarizing Posterior Simulations Using Random Variable Objects. Statistics and Computing 17:3, 235-244.

See also vignette("rv").

Examples

1
2
  x <- rvempirical(5, 1:10)
  z <- rvmatch(x, table=1:3, nomatch=0L)

rv documentation built on May 29, 2017, 8:53 p.m.

Search within the rv package
Search all R packages, documentation and source code