Learn R Programming

OpenMx (version 2.21.13)

mxAlgebraFromString: Create MxAlgebra object from a string

Description

Create MxAlgebra object from a string

Usage

mxAlgebraFromString(algString, name = NA, dimnames = NA, ...)

Arguments

algString

the character string to convert into an R expression

name

An optional character string indicating the name of the object.

dimnames

list. The dimnames attribute for the algebra: a list of length 2 giving the row and column names respectively. An empty list is treated as NULL, and a list of length one as row names. The list can be named, and the list names will be used as names for the dimensions.

...

Forwarded verbatim to mxAlgebra

See Also

mxAlgebra

Examples

Run this code
A <- mxMatrix(values = runif(25), nrow = 5, ncol = 5, name = 'A')
B <- mxMatrix(values = runif(25), nrow = 5, ncol = 5, name = 'B')
model <- mxModel(A, B, name = 'model',
  mxAlgebraFromString("A * (B + A)", name = 'test'))
model <- mxRun(model)
model[['test']]$result
A$values * (B$values + A$values)

Run the code above in your browser using DataLab