Description Usage Arguments Details Value Examples
Evaluates a function passed as a list with function name and named parameters.
1 | evalFunc(x, fun, p = 1)
|
x |
Numeric vector where |
fun |
A list with the function name and named parameters. See examples. |
p |
Positive integer with the position in |
Evaluates a function in a list with the function name and named parameters. x go to the first input parameter of the function f
.
If fun
is a list, the evaluation of fun
at points x
. If f
is not a list, the result is the input f
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # Example 1: no evaluation because f is already given.
evalFunc(x = 0:2, fun = 1)
evalFunc(x = 0:2, fun = 1:3)
# Example 2: function evaluation
fe <- list(fun = 'dnorm', mean = 3, sd = 2)
evalFunc(x = 0:2, fun = fe) # # dnorm(0:2, mean = 3, sd =2)
# Example 3: Function name not being the first element of the list fe.
fe <- list(mean = 1.5, sd = 2, f = 'dnorm')
evalFunc(x = 0:2, fun = fe, p = 3) # dnorm(0:2, mean = 1.5, sd =2)
# Example 4:
library(empiricalDistribution)
library(bernstein)
ex <- cbind(1:5, c(2, 4, 3, 6, 7)); print(ex)
set.seed(1); ex <- ex[sample(1:5), ]
eDiffEC <- forwardDifference(empiricalCDF2Dcounts(ex))
eu <- 0.3; ev <- 0.1
bernstein2DderivativeX(v = ev, u = eu, diffEC = eDiffEC)
efun <- list(fun = 'bernstein2DderivativeX', u = eu, diffEC = eDiffEC)
evalFunc(x = ev, fun = efun)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.