addrv: Adding Random Variables to a Probability Space

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Adds a column to a data frame probability space containing the values of a random variable computed from the existing columns of the space.

Usage

1
addrv(space, FUN = NULL, invars = NULL, name = NULL, ...)

Arguments

space

a data frame with a probs column.

FUN

a function to be applied to each row of outcomes in space

invars

a character vector indicating input columns of space

name

an (optional) name to give the defined random variable.

...

an expression defining a random variable.

Details

There are two ways to add a random variable to a data frame probability space; see the examples. The argument FUN has precedence and will be used if specified. If name is not specified, then the new random variable will be called X. Note that this function only works for data frames, as a method for objects of class ps has not been implemented.

Value

The input data frame with an additional column called name.

Author(s)

G. Jay Kerns gkerns@ysu.edu.

See Also

See transform to add a column to a data frame of outcomes (not yet a probability space).

Examples

1
2
3
S <-rolldie(3, makespace = TRUE)
addrv(S, sum, name = "Y")
addrv(S, Z = X3 - X2 )

aflaherty13/prob documentation built on May 28, 2019, 4:42 p.m.