Description Usage Arguments Details Examples
Replace variables in func
with values given in params
. Remove argument names from func
if necessary.
1 | substitute.parameters(func, params = as.list(environment(func)))
|
func |
a function or expression |
params |
a list of the form |
This is a convenient wrapper around the base function substitute
extended
by the possibility to substitute values in a function, possibly removing
arguments of the function according to which variables are to be replaced with values.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # a simple function
f <- function( a, b, c ) a + b + c
substitute.parameters( f, list( a = 1 ) )
# a is replaced by 1, the function looses the argument a
# function (b, c)
# 1 + b + c
substitute.parameters( f, list( a = quote(b) ))
# a is replaced with b, the function looses the argument a
# function (b, c)
# b + b + c
a = 10 # Set global value for a
substitute.parameters( f ) # no params argument given
# By default, params are taken from the environment of f
# function (b, c)
# 10 + b + c
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.