parseProbVec: Parses Probability Vector Strings

parseProbVecR Documentation

Parses Probability Vector Strings

Description

This takes a bunch of strings of the form "[High:.3,Med:.5,Low:.2]" and parses it into a vector c(High=.3,Med=.5,Low=.2).

Usage

parseProbVec(pVec)
parseProbVecRow(splitrow)

Arguments

pVec

A string of the form "[High:.3,Med:.5,Low:.2]"

splitrow

A collection of strings "High:.3", "Med:.5", "Low:.2".

Details

StatShop outputs marginal distributions in the format [state0:val0,state1:val1,...]. This function takes a vector of strings containing probability vectors and parses them, returning a matrix of the values, with column names given by the names of the states.

The function parseProbVecRow() is an internal function which parses a single row (after it has been split on the commas).

Value

A matrix containing the values. The rows correspond to the elements of pVec. The columns correspond to the state names.

Author(s)

Russell Almond

References

http://research.ets.org/~ralmond/StatShop/dataFormats.html

See Also

readHistory

Examples

  parseProbVec(c(Good = "[High:.8,Med:.15,Low:.05]",
                 Bad = "[High:.15,Med:.35,Low:.5]",
                 Ugly = "[High:.01,Med:.09,Low:.9]"))

ralmond/CPTtools documentation built on Dec. 27, 2024, 7:15 a.m.