subs: Substitute symbol for value

View source: R/subs.R

subsR 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 nms is substituted with (see Details)

Details

Two different ways to call this function is supported:

  1. Supplying nms as a named list and omitting vls. If two components have the same name, the behaviour is undefined.

  2. Supplying both nms and vls 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)
}


caracas documentation built on June 22, 2024, 10:59 a.m.