I would like to integrate a function with respect to x
,
FUN1 <- function(x, alpha, beta){
x * alpha - beta
}
FUN2 <- function(alpha beta){
integrate(FUN1(x, alpha,beta), 0,1)
}
But it does not work.
I also tried
FUN2 <- function(alpha beta){
integrate(FUN1, 0,1)
}
It does not work either.
Try this, and also read the docs,
f1 = function(x, a, b) x * a - b
f2 = function(a, b) integrate(f1, 0, 1, a, b) # a and b are passed to f1 through ...
f2(3, 4)