subs {caracas} | R Documentation |
Substitute symbol for value
Description
Substitute symbol for value
Usage
subs(sym, nms, vls)
Arguments
sym |
Expression |
nms |
Names of symbols (see Details) |
vls |
Values that |
Details
Two different ways to call this function is supported:
Supplying
nms
as a named list and omittingvls
. If two components have the same name, the behaviour is undefined.Supplying both
nms
andvls
See Examples.
Examples
if (has_sympy()) {
x <- symbol('x')
e <- 2*x^2
e
subs(e, "x", "2")
subs(e, x, 2)
subs(e, list(x = 2))
A <- matrix_sym(2, 2, "a")
B <- matrix_sym(2, 2, "b")
e <- A %*% A
subs(e, A, B)
}
[Package caracas version 2.1.1 Index]