Description Usage Arguments Details Value Author(s) See Also Examples

Substitute symbols in an `mvp`

object for numbers or other
multivariate polynomials

1 2 3 4 5 6 7 |

`S,X` |
Multivariate polynomials |

`...` |
named arguments corresponding to variables to substitute |

`lose` |
Boolean with default |

`v` |
A string corresponding to the variable to substitute |

`old,new,x` |
The old and new variable names respectively; |

Function `subs()`

substitutes variables for `mvp`

objects,
using a natural R idiom. Observe that this type of substitution is
sensitive to order:

1 2 3 4 5 6 7 |

Functions `subsy()`

and `subsmvp()`

are lower-level functions,
not really intended for the end-user. Function `subsy()`

substitutes variables for numeric values (order matters if a variable is
substituted more than once). Function `subsmpv()`

takes a
`mvp`

object and substitutes another `mvp`

object for a
specific symbol.

Function `subvec()`

substitutes the symbols of `S`

with
numerical values. It is vectorised in its ellipsis arguments with
recycling rules and names behaviour inherited from `cbind()`

.
However, if the first element of `...`

is a matrix, then this is
interpreted by rows, with symbol names given by the matrix column names;
further arguments are ignored. Unlike `subs()`

, this function is
generally only useful if all symbols are given a value; unassigned
symbols take a value of zero.

Function `varchange()`

makes a *formal* variable substitution.
It is useful because it can take non-standard variable names such as
“`(a-b)`

” or “`?`

”, and is used in
`taylor()`

. Function `varchange_formal()`

does the same task,
but takes two character vectors, `old`

and `new`

, which might
be more convenient than passing named arguments. Remember that
non-standard names might need to be quoted; also you might need to
escape some characters, see the examples. Function `namechanger()`

is a low-level helper function that uses regular expression idiom to
substitute variable names.

Functions `subs()`

, `subsy()`

and `subsmvp()`

return a
multivariate polynomial unless `lose`

is `TRUE`

in which
case a length one numeric vector is returned. Function
`subvec()`

returns a numeric vector (sic! the output inherits its
order from the arguments).

Robin K. S. Hankin

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ```
p <- rmvp(6,2,2,letters[1:3])
p
subs(p,a=1)
subs(p,a=1,b=2)
subs(p,a="1+b x^3",b="1-y")
subs(p,a=1,b=2,c=3,lose=FALSE)
do.call(subs,c(list(as.mvp("z")),rep(c(z="C+z^2"),5)))
subvec(p,a=1,b=2,c=1:5) # supply a named list of vectors
M <- matrix(sample(1:3,26*3,replace=TRUE),ncol=26)
colnames(M) <- letters
rownames(M) <- c("Huey", "Dewie", "Louie")
subvec(kahle(r=3,p=1:3),M) # supply a matrix
varchange(as.mvp("1+x+xy + x*y"),x="newx") # variable xy unchanged
kahle(5,3,1:3) %>% subs(a="a + delta")
pnew <- varchange(p,a="]") # nonstandard variable names OK
p111 <- varchange_formal(p,"\\]","a")
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.