Learn R Programming

GUIgems (version 0.1)

addStateMatrix: addStateMatrix

Description

Adds a new state to a transitions functions matrix.

Usage

addStateMatrix(newMatrix, oldMatrix,
               stateName=paste("state", after+1, sep=" "),
               after=dim(oldMatrix)[1], newCell="NULL")

Arguments

newMatrix
an empty matrix with one more row and one more column than the old
oldMatrix
a matrix to which we are adding a new state;
stateName
the name of the state to be added;
after
the number of the state after which a new state should be added
newCell
the value in the state to be added;

Value

newMatrix a matrix created by adding a new state with the value newCell to the old matrix

Examples

Run this code
M <- generateHazardMatrix(5)
largeM <- generateHazardMatrix(6)
oldM <- M@list.matrix
newM <- largeM@list.matrix
M_addedState <- addStateMatrix(newM, oldM, stateName ="newState", after =3, newCell=0)

Run the code above in your browser using DataLab