modify_call {lazy.symbolic}R Documentation

Wrap or Repalce a Call in an Expression

Description

Wrap or Repalce a Call in an Expression

Usage

modify_call(expr, old = NULL, new = NULL, replace = 0, which = 1, debug = 0)

Arguments

expr

an expression or a string

old

a call to be replaced or modified as a string

new

the new call as a string

replace

= 1 to replace old call by new one

which

a number or "all" to indicate which call(s) to be replaced

debug

= 1 to print intermediate results

Value

a string

Examples

# replace
expr="F( 1 + a*b )%*%H(X*Y)"
modify_call( expr,"*", "-", replace=1)
modify_call( expr,"*", "-", replace=1, which=2)

# wrap
expr="F( 1 + a*b )%*%H(X*Y)"
modify_call( expr,"*", "(")
modify_call( expr,"*", "(", which=2)
modify_call( expr,"*", "(", which="all")
modify_call( expr,"%*%", "(")
modify_call( expr,"*", "det")


[Package lazy.symbolic version 1.0.0.20250803 ]